From 91d04b99d1aea1a9814761b7010eb57e2cb95abd Mon Sep 17 00:00:00 2001 From: David Dreher Date: Fri, 22 Mar 2019 21:56:49 +0100 Subject: [PATCH] change filter function to find, find will match the first note with requested key --- browser/main/NoteList/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 60e11a79..912a7abb 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -269,10 +269,9 @@ class NoteList extends React.Component { const selectedNoteKeys = [noteHash] let locationToSelect = '/home' - const notesByHash = data.noteMap.map((note) => note).filter((note) => note.key === noteHash) - if (notesByHash.length > 0) { - const note = notesByHash[0] - locationToSelect = '/storages/' + note.storage + '/folders/' + note.folder + const noteByHash = data.noteMap.map((note) => note).find(note => { return note.key === noteHash }) + if (noteByHash !== undefined) { + locationToSelect = '/storages/' + noteByHash.storage + '/folders/' + noteByHash.folder } this.focusNote(selectedNoteKeys, noteHash, locationToSelect)