From 0b2bf1f816f22fe74465ad6d0efc74fa17ff92ac Mon Sep 17 00:00:00 2001 From: Shuo Wu Date: Tue, 26 May 2020 21:08:41 -0400 Subject: [PATCH] fix: add note --- extension/src/ui/store/videoNotes.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/extension/src/ui/store/videoNotes.js b/extension/src/ui/store/videoNotes.js index a65d965..9df17f6 100644 --- a/extension/src/ui/store/videoNotes.js +++ b/extension/src/ui/store/videoNotes.js @@ -100,18 +100,17 @@ const videoNotesModel = { createdAt: +new Date() }; page = await storage.addPage(pageObj); + } else { + // Add note + if (!page.notes.find(note => note.id === id)) { + const addedNote = await storage.addNote(page.id, { id, ...note }); + const notes = [...page.notes, addedNote].sort( + (n1, n2) => n1.timestamp - n2.timestamp + ); + page = { ...page, notes }; + } } - - // Add note - if (!page.notes.find(note => note.id === id)) { - const addedNote = await storage.addNote(page.id, { id, ...note }); - const notes = [...page.notes, addedNote].sort( - (n1, n2) => n1.timestamp - n2.timestamp - ); - page = { ...page, notes }; - actions.setPage(page); - } - + actions.setPage(page); actions.editor.reset(); }), removeNote: thunk(async (actions, noteId, { getState }) => {