prompt user when there are unsaved changes, #1692

This commit is contained in:
zadam
2021-02-27 23:39:02 +01:00
parent 02016ed031
commit 78e48095e6
5 changed files with 64 additions and 8 deletions

View File

@@ -54,8 +54,6 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.typeWidgets = {};
const updateInterval = utils.isDesktop() ? 1000 : 5000;
this.spacedUpdate = new SpacedUpdate(async () => {
const {note} = this.tabContext;
const {noteId} = note;
@@ -66,7 +64,9 @@ export default class NoteDetailWidget extends TabAwareWidget {
protectedSessionHolder.touchProtectedSessionIfNecessary(note);
await server.put('notes/' + noteId, dto, this.componentId);
}, updateInterval);
});
appContext.addBeforeUnloadListener(this);
}
isEnabled() {
@@ -295,7 +295,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
}
beforeUnloadEvent() {
this.spacedUpdate.updateNowIfNecessary();
return this.spacedUpdate.isAllSavedAndTriggerUpdate();
}
textPreviewDisabledEvent({tabContext}) {