fix(frontend): fix event emitter leak in realtime status

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-06-25 22:24:04 +02:00 committed by Philip Molares
parent b2cb54c225
commit 13a8eedb50

View file

@ -21,7 +21,7 @@ export const useSendRealtimeActivity = (messageTransporter: MessageTransporter)
const idling = useIdle(INACTIVITY_TIMEOUT_SECONDS * 1000)
useEffect(() => {
messageTransporter.doAsSoonAsReady(() => {
const listener = messageTransporter.doAsSoonAsReady(() => {
messageTransporter.sendMessage({
type: MessageType.REALTIME_USER_SET_ACTIVITY,
payload: {
@ -29,5 +29,9 @@ export const useSendRealtimeActivity = (messageTransporter: MessageTransporter)
}
})
})
return () => {
listener.off()
}
}, [active, idling, messageTransporter])
}