Skip to content

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

web: fix sidebar flickering when editing a note (#10506)

Abdullah Atta5748795b9920
diff --git a/apps/web/src/stores/note-store.ts b/apps/web/src/stores/note-store.ts
index 4c5dcd118..460dd74a5 100644
--- a/apps/web/src/stores/note-store.ts
+++ b/apps/web/src/stores/note-store.ts
@@ -58,7 +58,8 @@ class NoteStore extends BaseStore<NoteStore> {
};
setContext = async (context?: Context) => {
- this.set({ context, contextNotes: undefined });
+ if (!isSameContext(this.get().context, context))
+ this.set({ context, contextNotes: undefined });
const groupOptions =
context?.type === "notebook" ||
context?.type === "tag" ||
@@ -174,3 +175,9 @@ export function notesFromContext(context: Context) {
return db.monographs.all;
}
}
+
+function isSameContext(a?: Context, b?: Context) {
+ if (!a || !b) return a === b;
+ if (a.type !== b.type) return false;
+ return !("id" in a) || !("id" in b) || a.id === b.id;
+}