|
@@ -44,6 +44,7 @@ import {
|
|
import {
|
|
import {
|
|
FIREBASE_STORAGE_PREFIXES,
|
|
FIREBASE_STORAGE_PREFIXES,
|
|
HIDDEN_DISCONNECT_TIMEOUT,
|
|
HIDDEN_DISCONNECT_TIMEOUT,
|
|
|
|
+ RECONNECT_TOAST_DURATION,
|
|
STORAGE_KEYS,
|
|
STORAGE_KEYS,
|
|
SYNC_BROWSER_TABS_TIMEOUT,
|
|
SYNC_BROWSER_TABS_TIMEOUT,
|
|
} from "./app_constants";
|
|
} from "./app_constants";
|
|
@@ -84,7 +85,6 @@ import { Provider, useAtom } from "jotai";
|
|
import { jotaiStore, useAtomWithInitialValue } from "../jotai";
|
|
import { jotaiStore, useAtomWithInitialValue } from "../jotai";
|
|
import { reconcileElements } from "./collab/reconciliation";
|
|
import { reconcileElements } from "./collab/reconciliation";
|
|
import { parseLibraryTokensFromUrl, useHandleLibrary } from "../data/library";
|
|
import { parseLibraryTokensFromUrl, useHandleLibrary } from "../data/library";
|
|
-import { Toast } from "../components/Toast";
|
|
|
|
|
|
|
|
polyfill();
|
|
polyfill();
|
|
window.EXCALIDRAW_THROTTLE_RENDER = true;
|
|
window.EXCALIDRAW_THROTTLE_RENDER = true;
|
|
@@ -250,8 +250,8 @@ const PlusAppLinkJSX = (
|
|
|
|
|
|
const ExcalidrawWrapper = () => {
|
|
const ExcalidrawWrapper = () => {
|
|
const [errorMessage, setErrorMessage] = useState("");
|
|
const [errorMessage, setErrorMessage] = useState("");
|
|
- const [toast, setToast] = useState<AppState["toast"]>(null);
|
|
|
|
const disconnectRef = useRef(false);
|
|
const disconnectRef = useRef(false);
|
|
|
|
+ const toastRef = useRef<AppState["toast"]>(null);
|
|
let currentLangCode = languageDetector.detect() || defaultLang.code;
|
|
let currentLangCode = languageDetector.detect() || defaultLang.code;
|
|
if (Array.isArray(currentLangCode)) {
|
|
if (Array.isArray(currentLangCode)) {
|
|
currentLangCode = currentLangCode[0];
|
|
currentLangCode = currentLangCode[0];
|
|
@@ -482,17 +482,17 @@ const ExcalidrawWrapper = () => {
|
|
} else {
|
|
} else {
|
|
cancelPrevDisconnect();
|
|
cancelPrevDisconnect();
|
|
disconnect();
|
|
disconnect();
|
|
- setToast(null);
|
|
|
|
|
|
+ excalidrawAPI.setToast(null);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
cancelPrevDisconnect();
|
|
cancelPrevDisconnect();
|
|
if (!collabAPI.isCollaborating()) {
|
|
if (!collabAPI.isCollaborating()) {
|
|
- if (!toast && disconnectRef.current) {
|
|
|
|
- setToast({
|
|
|
|
|
|
+ if (!toastRef.current && disconnectRef.current) {
|
|
|
|
+ toastRef.current = {
|
|
message: t("toast.reconnectRoomServer"),
|
|
message: t("toast.reconnectRoomServer"),
|
|
- duration: Infinity,
|
|
|
|
|
|
+ duration: RECONNECT_TOAST_DURATION,
|
|
closable: true,
|
|
closable: true,
|
|
- });
|
|
|
|
|
|
+ };
|
|
}
|
|
}
|
|
disconnectRef.current &&
|
|
disconnectRef.current &&
|
|
(await initializeScene({ collabAPI, excalidrawAPI }).then(
|
|
(await initializeScene({ collabAPI, excalidrawAPI }).then(
|
|
@@ -504,12 +504,16 @@ const ExcalidrawWrapper = () => {
|
|
...data.scene,
|
|
...data.scene,
|
|
...restore(data.scene, null, null),
|
|
...restore(data.scene, null, null),
|
|
commitToHistory: true,
|
|
commitToHistory: true,
|
|
|
|
+ appState: {
|
|
|
|
+ ...excalidrawAPI.getAppState(),
|
|
|
|
+ toast: toastRef.current,
|
|
|
|
+ },
|
|
});
|
|
});
|
|
excalidrawAPI.scrollToContent();
|
|
excalidrawAPI.scrollToContent();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
));
|
|
));
|
|
- setToast(null);
|
|
|
|
|
|
+ toastRef.current = null;
|
|
disconnectRef.current = false;
|
|
disconnectRef.current = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -744,7 +748,7 @@ const ExcalidrawWrapper = () => {
|
|
return (
|
|
return (
|
|
<div
|
|
<div
|
|
style={{ height: "100%" }}
|
|
style={{ height: "100%" }}
|
|
- className={clsx("excalidraw-app excalidraw", {
|
|
|
|
|
|
+ className={clsx("excalidraw-app", {
|
|
"is-collaborating": isCollaborating,
|
|
"is-collaborating": isCollaborating,
|
|
})}
|
|
})}
|
|
>
|
|
>
|
|
@@ -794,14 +798,6 @@ const ExcalidrawWrapper = () => {
|
|
onClose={() => setErrorMessage("")}
|
|
onClose={() => setErrorMessage("")}
|
|
/>
|
|
/>
|
|
)}
|
|
)}
|
|
- {toast && (
|
|
|
|
- <Toast
|
|
|
|
- message={toast.message}
|
|
|
|
- duration={toast.duration}
|
|
|
|
- closable={toast.closable}
|
|
|
|
- onClose={() => setToast(null)}
|
|
|
|
- />
|
|
|
|
- )}
|
|
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
};
|
|
};
|