mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Merge 1053a51f64
into 192c4e7658
This commit is contained in:
commit
dcd010c475
4 changed files with 29 additions and 13 deletions
|
@ -482,7 +482,7 @@ const ExcalidrawWrapper = () => {
|
|||
collabAPI?.isCollaborating() &&
|
||||
!isCollaborationLink(window.location.href)
|
||||
) {
|
||||
collabAPI.stopCollaboration(false);
|
||||
await collabAPI.stopCollaboration(false);
|
||||
}
|
||||
excalidrawAPI.updateScene({ appState: { isLoading: true } });
|
||||
|
||||
|
@ -980,9 +980,9 @@ const ExcalidrawWrapper = () => {
|
|||
"exit",
|
||||
"collaboration",
|
||||
],
|
||||
perform: () => {
|
||||
perform: async () => {
|
||||
if (collabAPI) {
|
||||
collabAPI.stopCollaboration();
|
||||
await collabAPI.stopCollaboration();
|
||||
if (!collabAPI.isCollaborating()) {
|
||||
setShareDialogState({ isOpen: false });
|
||||
}
|
||||
|
|
|
@ -352,13 +352,14 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||
}
|
||||
};
|
||||
|
||||
stopCollaboration = (keepRemoteState = true) => {
|
||||
stopCollaboration = async (keepRemoteState = true) => {
|
||||
this.queueBroadcastAllElements.cancel();
|
||||
this.queueSaveToFirebase.cancel();
|
||||
this.loadImageFiles.cancel();
|
||||
this.resetErrorIndicator(true);
|
||||
|
||||
this.saveCollabRoomToFirebase(
|
||||
// Ensure we save the latest state before stopping collaboration
|
||||
await this.saveCollabRoomToFirebase(
|
||||
getSyncableElements(
|
||||
this.excalidrawAPI.getSceneElementsIncludingDeleted(),
|
||||
),
|
||||
|
@ -379,6 +380,9 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||
// that could have been saved in other tabs while we were collaborating
|
||||
resetBrowserStateVersions();
|
||||
|
||||
// Ensure all pending changes are saved before pushing new state
|
||||
this.queueSaveToFirebase.flush();
|
||||
|
||||
window.history.pushState({}, APP_NAME, window.location.origin);
|
||||
this.destroySocketClient();
|
||||
|
||||
|
@ -950,9 +954,9 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||
}, SYNC_FULL_SCENE_INTERVAL_MS);
|
||||
|
||||
queueSaveToFirebase = throttle(
|
||||
() => {
|
||||
async () => {
|
||||
if (this.portal.socketInitialized) {
|
||||
this.saveCollabRoomToFirebase(
|
||||
await this.saveCollabRoomToFirebase(
|
||||
getSyncableElements(
|
||||
this.excalidrawAPI.getSceneElementsIncludingDeleted(),
|
||||
),
|
||||
|
|
|
@ -165,10 +165,9 @@ const ActiveRoomDialog = ({
|
|||
icon={playerStopFilledIcon}
|
||||
onClick={() => {
|
||||
trackEvent("share", "room closed");
|
||||
collabAPI.stopCollaboration();
|
||||
if (!collabAPI.isCollaborating()) {
|
||||
collabAPI.stopCollaboration().then(() => {
|
||||
handleClose();
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue