web: fix crash on refreshing editor store

This commit is contained in:
Abdullah Atta
2024-03-07 12:43:06 +05:00
parent c1f4a4e3ab
commit 36cf1fb950

View File

@@ -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,