From 13a8eedb5024c1c469e51bcb264238ff2acf8669 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 25 Jun 2023 22:24:04 +0200 Subject: [PATCH] fix(frontend): fix event emitter leak in realtime status Signed-off-by: Tilman Vatteroth --- .../editor-pane/hooks/yjs/use-send-realtime-activity.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-send-realtime-activity.ts b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-send-realtime-activity.ts index a186dd02b..0165e310f 100644 --- a/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-send-realtime-activity.ts +++ b/frontend/src/components/editor-page/editor-pane/hooks/yjs/use-send-realtime-activity.ts @@ -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]) }