From 52254bca7ce9fcbb8caca9d6298bbec8b8e6446f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arno=C5=A1t=20Pleskot?= Date: Fri, 2 Jun 2023 10:25:58 +0200 Subject: [PATCH] fix: do not fire pause logic on window focus/blur event --- src/excalidraw-app/collab/Collab.tsx | 1 + src/excalidraw-app/index.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/excalidraw-app/collab/Collab.tsx b/src/excalidraw-app/collab/Collab.tsx index 6b03d4239..1cadd0eae 100644 --- a/src/excalidraw-app/collab/Collab.tsx +++ b/src/excalidraw-app/collab/Collab.tsx @@ -334,6 +334,7 @@ class Collab extends PureComponent { if (this.portal.socket) { this.reportActive(); this.portal.socket.connect(); + this.portal.socketInitialized = true; this.setIsCollaborationPaused(false); if (callback) { diff --git a/src/excalidraw-app/index.tsx b/src/excalidraw-app/index.tsx index dd1b383db..051e1f76a 100644 --- a/src/excalidraw-app/index.tsx +++ b/src/excalidraw-app/index.tsx @@ -476,7 +476,9 @@ const ExcalidrawWrapper = () => { event.type === EVENT.FOCUS ) { syncData(); + } + if (event.type === EVENT.VISIBILITY_CHANGE) { switch (true) { // user switches to another tab case document.hidden && collabAPI.isCollaborating():