[🐴] Suspend event bus when switching accounts (#4190)
* Suspend event bus when switching accounts * Make effect symmetricalzio/stable
parent
efdcfd09e6
commit
2c6c906934
|
@ -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])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue