Skip to content

Commit 02f1f6c

Browse files
committed
Prevent spurious update event on note creation
When a note is created, moveNoteToFront() is called. This triggers an "update" event even when the note is already at the top of the stack. Make it so moveNoteToFront() is a no-op when the note is already at the top. Signed-off-by: Simon Ser <[email protected]>
1 parent 1f31384 commit 02f1f6c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/app/services/data/note.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export class NoteService {
246246

247247
moveNoteToFront(noteId: number, enforceUpdate = true) {
248248
const note = this.getNoteFromId(noteId);
249+
if (this.notesStore.notes.at(-1) === note) return;
249250
this.notesStore.notes = this.notesStore.notes.filter((n: Note) => n.getId() !== noteId);
250251
this.notesStore.notes.push(note);
251252
if (enforceUpdate) {

0 commit comments

Comments
 (0)