Warn to save content

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2024-09-23 12:12:58 +02:00
parent 8ca4cf3260
commit fe318126bd
No known key found for this signature in database
4 changed files with 97 additions and 2 deletions

View file

@ -126,6 +126,8 @@ import DebugCanvas, {
loadSavedDebugState,
} from "./components/DebugCanvas";
import { AIComponents } from "./components/AI";
import type { SaveWarningRef } from "./components/SaveWarning";
import { SaveWarning } from "./components/SaveWarning";
polyfill();
@ -331,6 +333,8 @@ const ExcalidrawWrapper = () => {
const [langCode, setLangCode] = useAppLangCode();
const activityRef = useRef<SaveWarningRef | null>(null);
// initial state
// ---------------------------------------------------------------------------
@ -615,6 +619,8 @@ const ExcalidrawWrapper = () => {
collabAPI.syncElements(elements);
}
activityRef.current?.activity();
// this check is redundant, but since this is a hot path, it's best
// not to evaludate the nested expression every time
if (!LocalData.isSavePaused()) {
@ -856,6 +862,7 @@ const ExcalidrawWrapper = () => {
setTheme={(theme) => setAppTheme(theme)}
refresh={() => forceRefresh((prev) => !prev)}
/>
<SaveWarning ref={activityRef} />
<AppWelcomeScreen
onCollabDialogOpen={onCollabDialogOpen}
isCollabEnabled={!isCollabDisabled}