Skip to content

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

web: ignore realtime sync if it doesn't update content or note title

Abdullah Atta8b0750820499
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index ac45f1c9f..3e1394511 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -174,7 +174,6 @@ function EditorView({
!item ||
isDeleted(item) ||
(item.type !== "tiptap" && item.type !== "note") ||
- lastChangedTime.current >= (item.dateEdited as number) ||
!appstore.get().isRealtimeSyncEnabled
) {
console.log("ignoring real time sync");
@@ -184,7 +183,7 @@ function EditorView({
const isContent =
item.type === "tiptap" && item.noteId === session.note.id;
const isNote = item.type === "note" && item.id === session.note.id;
- if (isContent) {
+ if (isContent && lastChangedTime.current < item.dateEdited) {
if (!item.locked) return editor.updateContent(item.data);
const result = await db.vault
@@ -192,15 +191,11 @@ function EditorView({
.catch(() => EV.publish(EVENTS.vaultLocked));
if (!result) return;
editor.updateContent(result.data);
- } else if (isNote) {
- useEditorStore
- .getState()
- .updateSession(session.id, [session.type], { note: item });
- if (item.title)
- AppEventManager.publish(AppEvents.changeNoteTitle, {
- title: item.title,
- preventSave: true
- });
+ } else if (isNote && session.note.title !== item.title) {
+ AppEventManager.publish(AppEvents.changeNoteTitle, {
+ title: item.title,
+ preventSave: true
+ });
}
}
);