Try new saving technique for PWA
This commit is contained in:
@ -16,21 +16,7 @@ const handleResize = (canvas: HTMLCanvasElement) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const installWindowBehaviors = (
|
const saveBeforeExit = (app: Editor): void => {
|
||||||
app: Editor,
|
|
||||||
window: Window,
|
|
||||||
preventMultipleTabs: boolean = false
|
|
||||||
) => {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.addEventListener("resize", () =>
|
|
||||||
handleResize(app.interface.scope as HTMLCanvasElement)
|
|
||||||
);
|
|
||||||
window.addEventListener("resize", () =>
|
|
||||||
handleResize(app.interface.feedback as HTMLCanvasElement)
|
|
||||||
);
|
|
||||||
window.addEventListener("beforeunload", () => {
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// Iterate over all local files and set the candidate to the committed
|
// Iterate over all local files and set the candidate to the committed
|
||||||
@ -39,6 +25,25 @@ export const installWindowBehaviors = (
|
|||||||
app.settings.saveApplicationToLocalStorage(app.universes, app.settings);
|
app.settings.saveApplicationToLocalStorage(app.universes, app.settings);
|
||||||
app.clock.stop();
|
app.clock.stop();
|
||||||
return null;
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const installWindowBehaviors = (
|
||||||
|
app: Editor,
|
||||||
|
window: Window,
|
||||||
|
preventMultipleTabs: boolean = false
|
||||||
|
) => {
|
||||||
|
|
||||||
|
window.addEventListener("resize", () =>
|
||||||
|
handleResize(app.interface.scope as HTMLCanvasElement)
|
||||||
|
);
|
||||||
|
window.addEventListener("resize", () =>
|
||||||
|
handleResize(app.interface.feedback as HTMLCanvasElement)
|
||||||
|
);
|
||||||
|
window.addEventListener("beforeunload", () => {
|
||||||
|
saveBeforeExit(app)
|
||||||
|
});
|
||||||
|
window.addEventListener("visibilitychange", () => {
|
||||||
|
saveBeforeExit(app)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (preventMultipleTabs) {
|
if (preventMultipleTabs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user