File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 || ' ' ;
You can’t perform that action at this time.
0 commit comments