mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
fix: disconnect message transporter on editor leave
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
165cd4c7a3
commit
220bb31f0c
1 changed files with 2 additions and 0 deletions
|
@ -94,6 +94,8 @@ export const useRealtimeConnection = (): MessageTransporter => {
|
||||||
return () => window.removeEventListener('beforeunload', disconnectCallback)
|
return () => window.removeEventListener('beforeunload', disconnectCallback)
|
||||||
}, [messageTransporter])
|
}, [messageTransporter])
|
||||||
|
|
||||||
|
useEffect(() => () => messageTransporter.disconnect(), [messageTransporter])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const connectedListener = messageTransporter.doAsSoonAsReady(() => setRealtimeConnectionState(true))
|
const connectedListener = messageTransporter.doAsSoonAsReady(() => setRealtimeConnectionState(true))
|
||||||
const disconnectedListener = messageTransporter.on('disconnected', () => setRealtimeConnectionState(false), {
|
const disconnectedListener = messageTransporter.on('disconnected', () => setRealtimeConnectionState(false), {
|
||||||
|
|
Loading…
Reference in a new issue