fix: disconnect message transporter on editor leave

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-04-14 18:25:53 +02:00
parent 165cd4c7a3
commit 220bb31f0c

View file

@ -94,6 +94,8 @@ export const useRealtimeConnection = (): MessageTransporter => {
return () => window.removeEventListener('beforeunload', disconnectCallback)
}, [messageTransporter])
useEffect(() => () => messageTransporter.disconnect(), [messageTransporter])
useEffect(() => {
const connectedListener = messageTransporter.doAsSoonAsReady(() => setRealtimeConnectionState(true))
const disconnectedListener = messageTransporter.on('disconnected', () => setRealtimeConnectionState(false), {