From 36cf1fb9502dbbf2a81012adcfd16a4bc9441eee Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Thu, 7 Mar 2024 12:43:06 +0500 Subject: [PATCH] web: fix crash on refreshing editor store --- apps/web/src/stores/editor-store.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 { // }); }; - 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 = ( id: string,