From cb956c5508d5716f5d4cbe52a88d3bb289fa07b7 Mon Sep 17 00:00:00 2001 From: Mika Andrianarijaona Date: Sat, 11 Aug 2018 11:44:22 +0200 Subject: [PATCH] Use default value config.sortBy - for new folders - for folders with no config set --- browser/main/NoteList/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 23e3fb77..94b32f4c 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -912,9 +912,10 @@ class NoteList extends React.Component { const { location, config, params: { folderKey } } = this.props let { notes } = this.props const { selectedNoteKeys } = this.state - const sortFunc = _.get(config, [folderKey, 'sortBy']) === 'CREATED_AT' + const sortBy = _.get(config, [folderKey, 'sortBy'], config.sortBy) + const sortFunc = sortBy === 'CREATED_AT' ? sortByCreatedAt - : _.get(config, [folderKey, 'sortBy']) === 'ALPHABETICAL' + : sortBy === 'ALPHABETICAL' ? sortByAlphabetical : sortByUpdatedAt const sortedNotes = location.pathname.match(/\/starred|\/trash/) @@ -965,7 +966,7 @@ class NoteList extends React.Component { notes.length === 1 || (autoSelectFirst && index === 0) const dateDisplay = moment( - _.get(config, [folderKey, 'sortBy']) === 'CREATED_AT' + sortBy === 'CREATED_AT' ? note.createdAt : note.updatedAt ).fromNow('D') @@ -1014,7 +1015,7 @@ class NoteList extends React.Component {