Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions browser/main/NoteList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
({
Expand Down Expand Up @@ -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
Expand All @@ -1134,6 +1149,7 @@ class NoteList extends React.Component {
if (note.isTrashed !== true || location.pathname === '/trashed')
return true
})
if (sortDir === 'DESCENDING') this.notes.reverse()

moment.updateLocale('en', {
relativeTime: {
Expand Down Expand Up @@ -1241,6 +1257,30 @@ class NoteList extends React.Component {
</select>
</div>
<div styleName='control-button-area'>
<button
title={i18n.__('Ascending Order')}
styleName={
config.listDirection === 'ASCENDING'
? 'control-button--active'
: 'control-button'
}
onClick={e => this.handleListDirectionButtonClick(e, 'ASCENDING')}
>
<img src='../resources/icon/icon-up.svg' />
</button>
<button
title={i18n.__('Descending Order')}
styleName={
config.listDirection === 'DESCENDING'
? 'control-button--active'
: 'control-button'
}
onClick={e =>
this.handleListDirectionButtonClick(e, 'DESCENDING')
}
>
<img src='../resources/icon/icon-down.svg' />
</button>
<button
title={i18n.__('Default View')}
styleName={
Expand Down
1 change: 1 addition & 0 deletions browser/main/lib/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const DEFAULT_CONFIG = {
},
sortTagsBy: 'ALPHABETICAL', // 'ALPHABETICAL', 'COUNTER'
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
listDirection: 'ASCENDING', // 'ASCENDING', 'DESCENDING'
amaEnabled: true,
autoUpdateEnabled: true,
hotkey: {
Expand Down
17 changes: 17 additions & 0 deletions resources/icon/icon-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.