mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Chunking incoming WS messages
This commit is contained in:
parent
1abb901ec2
commit
12be5d716b
6 changed files with 405 additions and 173 deletions
|
@ -56,7 +56,7 @@ import Collab, {
|
|||
collabAPIAtom,
|
||||
isCollaboratingAtom,
|
||||
isOfflineAtom,
|
||||
syncAPIAtom,
|
||||
syncApiAtom,
|
||||
} from "./collab/Collab";
|
||||
import {
|
||||
exportToBackend,
|
||||
|
@ -139,7 +139,6 @@ import type { ElementsChange } from "../packages/excalidraw/change";
|
|||
|
||||
import Slider from "rc-slider";
|
||||
import "rc-slider/assets/index.css";
|
||||
import { SyncClient } from "../packages/excalidraw/sync/client";
|
||||
|
||||
polyfill();
|
||||
|
||||
|
@ -370,7 +369,7 @@ const ExcalidrawWrapper = () => {
|
|||
|
||||
const [, setShareDialogState] = useAtom(shareDialogStateAtom);
|
||||
const [collabAPI] = useAtom(collabAPIAtom);
|
||||
const [syncAPI] = useAtom(syncAPIAtom);
|
||||
const [syncAPI] = useAtom(syncApiAtom);
|
||||
const [nextVersion, setNextVersion] = useState(-1);
|
||||
const currentVersion = useRef(-1);
|
||||
const [acknowledgedIncrements, setAcknowledgedIncrements] = useState<
|
||||
|
@ -389,7 +388,7 @@ const ExcalidrawWrapper = () => {
|
|||
syncAPI?.connect();
|
||||
|
||||
return () => {
|
||||
syncAPI?.disconnect(SyncClient.NORMAL_CLOSURE);
|
||||
syncAPI?.disconnect();
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [syncAPI]);
|
||||
|
@ -890,7 +889,7 @@ const ExcalidrawWrapper = () => {
|
|||
// CFDO: in safari the whole canvas gets selected when dragging
|
||||
if (value !== acknowledgedIncrements.length) {
|
||||
// don't listen to updates in the detached mode
|
||||
syncAPI?.disconnect(SyncClient.NORMAL_CLOSURE);
|
||||
syncAPI?.disconnect();
|
||||
} else {
|
||||
// reconnect once we're back to the latest version
|
||||
syncAPI?.connect();
|
||||
|
|
|
@ -90,7 +90,7 @@ import type {
|
|||
} from "../../packages/excalidraw/data/reconcile";
|
||||
import { SyncClient } from "../../packages/excalidraw/sync/client";
|
||||
|
||||
export const syncAPIAtom = atom<SyncClient | null>(null);
|
||||
export const syncApiAtom = atom<SyncClient | null>(null);
|
||||
export const collabAPIAtom = atom<CollabAPI | null>(null);
|
||||
export const isCollaboratingAtom = atom(false);
|
||||
export const isOfflineAtom = atom(false);
|
||||
|
@ -239,7 +239,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||
|
||||
SyncClient.create(this.excalidrawAPI, SyncIndexedDBAdapter).then(
|
||||
(syncAPI) => {
|
||||
appJotaiStore.set(syncAPIAtom, syncAPI);
|
||||
appJotaiStore.set(syncApiAtom, syncAPI);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -276,6 +276,8 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||
window.clearTimeout(this.idleTimeoutId);
|
||||
this.idleTimeoutId = null;
|
||||
}
|
||||
|
||||
appJotaiStore.get(syncApiAtom)?.disconnect();
|
||||
this.onUmmount?.();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue