From d706a5375c9ef488eb9ba28cafc05b07181029af Mon Sep 17 00:00:00 2001 From: Alex Garrity Date: Sun, 16 Feb 2020 23:49:49 +0000 Subject: [PATCH] Added sorting direction buttons --- browser/main/NoteList/index.js | 40 +++++++++++++++++++++++++++++++ browser/main/lib/ConfigManager.js | 1 + resources/icon/icon-up.svg | 17 +++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 resources/icon/icon-up.svg diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 9b9b7de0..19387acf 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -581,6 +581,20 @@ class NoteList extends React.Component { }) } + handleListDirectionButtonClick(e, direction) { + const { dispatch } = this.props + + const config = { + listDirection: direction + } + + ConfigManager.set(config) + dispatch({ + type: 'SET_CONFIG', + config + }) + } + alertIfSnippet(msg) { const warningMessage = msg => ({ @@ -1120,6 +1134,7 @@ class NoteList extends React.Component { let { notes } = this.props const { selectedNoteKeys } = this.state const sortBy = _.get(config, [folderKey, 'sortBy'], config.sortBy.default) + const sortDir = config.listDirection const sortFunc = sortBy === 'CREATED_AT' ? sortByCreatedAt @@ -1129,6 +1144,7 @@ class NoteList extends React.Component { const sortedNotes = location.pathname.match(/\/starred|\/trash/) ? this.getNotes().sort(sortFunc) : this.sortByPin(this.getNotes().sort(sortFunc)) + if (sortDir === 'DESCENDING') sortedNotes.reverse() this.notes = notes = sortedNotes.filter(note => { // this is for the trash box if (note.isTrashed !== true || location.pathname === '/trashed') @@ -1241,6 +1257,30 @@ class NoteList extends React.Component {
+ +