Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix crash on refreshing editor store

Abdullah Atta0c0d91f8fd47
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts
index 014c4b237..afdd86700 100644
--- a/apps/web/src/stores/editor-store.ts
+++ b/apps/web/src/stores/editor-store.ts
@@ -223,11 +223,15 @@ class EditorStore extends BaseStore<EditorStore> {
// });
};
- async refresh() {
- // const sessionId = this.get().session.id;
- // if (sessionId && !(await db.notes.exists(sessionId)))
- // await this.clearSession();
- }
+ refresh = async () => {
+ const { sessions, closeSessions } = this.get();
+ const clearIds = [];
+ for (const session of sessions) {
+ if ("note" in session && !(await db.notes.exists(session.note.id)))
+ clearIds.push(session.id);
+ }
+ if (clearIds.length > 0) closeSessions(...clearIds);
+ };
updateSession = <T extends SessionType[]>(
id: string,