[🐴] Suspend event bus when switching accounts (#4190)

* Suspend event bus when switching accounts

* Make effect symmetrical
zio/stable
Eric Bailey 2024-05-23 10:08:37 -05:00 committed by GitHub
parent efdcfd09e6
commit 2c6c906934
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -1,10 +1,8 @@
import React from 'react' import React from 'react'
import {AppState} from 'react-native' import {AppState} from 'react-native'
import {isWeb} from '#/platform/detection'
import {MessagesEventBus} from '#/state/messages/events/agent' import {MessagesEventBus} from '#/state/messages/events/agent'
import {useAgent} from '#/state/session' import {useAgent} from '#/state/session'
import {IS_DEV} from '#/env'
const MessagesEventBusContext = React.createContext<MessagesEventBus | null>( const MessagesEventBusContext = React.createContext<MessagesEventBus | null>(
null, null,
@ -32,9 +30,10 @@ export function MessagesEventBusProvider({
) )
React.useEffect(() => { React.useEffect(() => {
if (isWeb && IS_DEV) { bus.resume()
// @ts-ignore
window.bus = bus return () => {
bus.suspend()
} }
}, [bus]) }, [bus])