From 2c6c906934a0b567e4e63025d1f69d534776b79d Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 23 May 2024 10:08:37 -0500 Subject: [PATCH] =?UTF-8?q?[=F0=9F=90=B4]=20Suspend=20event=20bus=20when?= =?UTF-8?q?=20switching=20accounts=20(#4190)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Suspend event bus when switching accounts * Make effect symmetrical --- src/state/messages/events/index.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/state/messages/events/index.tsx b/src/state/messages/events/index.tsx index b0be73b1..6bf79232 100644 --- a/src/state/messages/events/index.tsx +++ b/src/state/messages/events/index.tsx @@ -1,10 +1,8 @@ import React from 'react' import {AppState} from 'react-native' -import {isWeb} from '#/platform/detection' import {MessagesEventBus} from '#/state/messages/events/agent' import {useAgent} from '#/state/session' -import {IS_DEV} from '#/env' const MessagesEventBusContext = React.createContext( null, @@ -32,9 +30,10 @@ export function MessagesEventBusProvider({ ) React.useEffect(() => { - if (isWeb && IS_DEV) { - // @ts-ignore - window.bus = bus + bus.resume() + + return () => { + bus.suspend() } }, [bus])