From e60f4f4a64cc3baf4d450bad2b0a06e6fe95970e Mon Sep 17 00:00:00 2001 From: Nathaniel Watson Date: Mon, 30 Oct 2017 21:51:44 +1300 Subject: [PATCH] Include each note only once when sorting by pin Fixes #983 --- browser/main/NoteList/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 5729d476..0dbafdf6 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -285,11 +285,18 @@ class NoteList extends React.Component { } sortByPin (unorderedNotes) { - const pinnedNotes = unorderedNotes.filter((note) => { - return note.isPinned + const pinnedNotes = [] + const unpinnedNotes = [] + + unorderedNotes.forEach((note) => { + if (note.isPinned) { + pinnedNotes.push(note) + } else { + unpinnedNotes.push(note) + } }) - return pinnedNotes.concat(unorderedNotes) + return pinnedNotes.concat(unpinnedNotes) } handleNoteClick (e, uniqueKey) {