fix: properly sync after reconnecting
This commit is contained in:
parent
2ffeff442a
commit
0567af1bcb
@ -322,7 +322,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
|
|
||||||
onPauseCollaborationChange = (state: PauseCollaborationState) => {
|
onPauseCollaborationChange = (state: PauseCollaborationState) => {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PauseCollaborationState.PAUSE: {
|
case PauseCollaborationState.PAUSED: {
|
||||||
if (this.portal.socket) {
|
if (this.portal.socket) {
|
||||||
this.portal.socket.disconnect();
|
this.portal.socket.disconnect();
|
||||||
this.portal.socketInitialized = false;
|
this.portal.socketInitialized = false;
|
||||||
@ -334,10 +334,9 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PauseCollaborationState.RESUME: {
|
case PauseCollaborationState.RESUMED: {
|
||||||
if (this.portal.socket && this.isPaused()) {
|
if (this.portal.socket && this.isPaused()) {
|
||||||
this.portal.socket.connect();
|
this.portal.socket.connect();
|
||||||
this.portal.socketInitialized = true;
|
|
||||||
this.portal.socket.emit(WS_SCENE_EVENT_TYPES.INIT);
|
this.portal.socket.emit(WS_SCENE_EVENT_TYPES.INIT);
|
||||||
|
|
||||||
this.excalidrawAPI.setToast({
|
this.excalidrawAPI.setToast({
|
||||||
@ -349,7 +348,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PauseCollaborationState.SYNC: {
|
case PauseCollaborationState.SYNCED: {
|
||||||
if (this.isPaused()) {
|
if (this.isPaused()) {
|
||||||
this.setIsCollaborationPaused(false);
|
this.setIsCollaborationPaused(false);
|
||||||
|
|
||||||
@ -560,7 +559,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
elements: reconciledElements,
|
elements: reconciledElements,
|
||||||
scrollToContent: true,
|
scrollToContent: true,
|
||||||
});
|
});
|
||||||
this.onPauseCollaborationChange(PauseCollaborationState.SYNC);
|
this.onPauseCollaborationChange(PauseCollaborationState.SYNCED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -568,7 +567,6 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
this.handleRemoteSceneUpdate(
|
this.handleRemoteSceneUpdate(
|
||||||
this.reconcileElements(decryptedData.payload.elements),
|
this.reconcileElements(decryptedData.payload.elements),
|
||||||
);
|
);
|
||||||
this.onPauseCollaborationChange(PauseCollaborationState.SYNC);
|
|
||||||
break;
|
break;
|
||||||
case "MOUSE_LOCATION": {
|
case "MOUSE_LOCATION": {
|
||||||
const { pointer, button, username, selectedElementIds } =
|
const { pointer, button, username, selectedElementIds } =
|
||||||
@ -757,7 +755,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
this.activeIntervalId = null;
|
this.activeIntervalId = null;
|
||||||
}
|
}
|
||||||
this.pauseTimeoutId = window.setTimeout(
|
this.pauseTimeoutId = window.setTimeout(
|
||||||
() => this.onPauseCollaborationChange(PauseCollaborationState.PAUSE),
|
() => this.onPauseCollaborationChange(PauseCollaborationState.PAUSED),
|
||||||
PAUSE_COLLABORATION_TIMEOUT,
|
PAUSE_COLLABORATION_TIMEOUT,
|
||||||
);
|
);
|
||||||
this.onIdleStateChange(UserIdleState.AWAY);
|
this.onIdleStateChange(UserIdleState.AWAY);
|
||||||
@ -770,7 +768,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
this.onIdleStateChange(UserIdleState.ACTIVE);
|
this.onIdleStateChange(UserIdleState.ACTIVE);
|
||||||
if (this.pauseTimeoutId) {
|
if (this.pauseTimeoutId) {
|
||||||
window.clearTimeout(this.pauseTimeoutId);
|
window.clearTimeout(this.pauseTimeoutId);
|
||||||
this.onPauseCollaborationChange(PauseCollaborationState.RESUME);
|
this.onPauseCollaborationChange(PauseCollaborationState.RESUMED);
|
||||||
this.pauseTimeoutId = null;
|
this.pauseTimeoutId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,9 +377,9 @@ export enum UserIdleState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum PauseCollaborationState {
|
export enum PauseCollaborationState {
|
||||||
PAUSE = "pause",
|
PAUSED = "paused",
|
||||||
RESUME = "resume",
|
RESUMED = "resumed",
|
||||||
SYNC = "sync",
|
SYNCED = "synced",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExportOpts = {
|
export type ExportOpts = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user