Skip to content

Commit 2dec94b

Browse files
authored
Merge pull request #776 from RedisInsight/bugfix/RI-3070
#RI-3070 - fix multiple subscriptions
2 parents 4a521cc + 4851518 commit 2dec94b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

redisinsight/ui/src/components/pub-sub-config/PubSubConfig.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ const PubSubConfig = ({ retryDelay = 5000 } : IProps) => {
9999
const onChannelsSubscribe = () => {
100100
dispatch(setLoading(false))
101101
dispatch(setIsPubSubSubscribed())
102-
103102
subscriptions.forEach(({ channel, type }: PubSubSubscription) => {
104-
socketRef.current?.on(`${type}:${channel}`, (data) => {
105-
dispatch(concatPubSubMessages(data))
106-
})
103+
const subscription = `${type}:${channel}`
104+
const isListenerExist = !!socketRef.current?.listeners(subscription).length
105+
106+
if (!isListenerExist) {
107+
socketRef.current?.on(subscription, (data) => {
108+
dispatch(concatPubSubMessages(data))
109+
})
110+
}
107111
})
108112
}
109113

0 commit comments

Comments
 (0)