Skip to content

Commit 9490d2b

Browse files
authored
Merge pull request #114 from djedi/fix/SSE-notification-bug
Fix false SSE warning on local save
2 parents 6f5199c + e1800cf commit 9490d2b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

client/src/views/Day.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,16 @@ const saveDay = async (isAutoSave: boolean = false) => {
172172
isSaving.value = true;
173173
const updatedDay = Object.assign(day.value, { data: modifiedText.value });
174174
175+
// Mark as locally updated BEFORE the API call to prevent SSE race condition
176+
// (SSE event can arrive before the await returns)
177+
if (day.value.uuid) {
178+
markNoteUpdatedLocally(day.value.uuid);
179+
}
180+
175181
try {
176182
const res = await NoteService.saveDay(updatedDay);
177-
// Mark as locally updated to prevent SSE duplicate processing
178-
if (res.uuid) {
183+
// Also mark after save in case it's a new note that just got a uuid
184+
if (res.uuid && res.uuid !== day.value.uuid) {
179185
markNoteUpdatedLocally(res.uuid);
180186
}
181187
text.value = modifiedText.value;

client/src/views/Note.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ const saveNote = async (isAutoSave: boolean = false) => {
127127
isSaving.value = true;
128128
const updatedNote = Object.assign(note.value, { data: modifiedText.value });
129129
130+
// Mark as locally updated BEFORE the API call to prevent SSE race condition
131+
// (SSE event can arrive before the await returns)
132+
if (note.value.uuid) {
133+
markNoteUpdatedLocally(note.value.uuid);
134+
}
135+
130136
try {
131137
note.value = await NoteService.saveNote(updatedNote);
132-
// Mark as locally updated to prevent SSE duplicate processing
133-
if (note.value.uuid) {
134-
markNoteUpdatedLocally(note.value.uuid);
135-
}
136138
text.value = modifiedText.value;
137139
// Don't reset modifiedText - it's already correct and resetting causes editor glitches
138140
headerOptions.title = note.value.title || '';

0 commit comments

Comments
 (0)