@@ -581,6 +581,20 @@ class NoteList extends React.Component {
581
581
} )
582
582
}
583
583
584
+ handleListDirectionButtonClick ( e , direction ) {
585
+ const { dispatch } = this . props
586
+
587
+ const config = {
588
+ listDirection : direction
589
+ }
590
+
591
+ ConfigManager . set ( config )
592
+ dispatch ( {
593
+ type : 'SET_CONFIG' ,
594
+ config
595
+ } )
596
+ }
597
+
584
598
alertIfSnippet ( msg ) {
585
599
const warningMessage = msg =>
586
600
( {
@@ -1120,6 +1134,7 @@ class NoteList extends React.Component {
1120
1134
let { notes } = this . props
1121
1135
const { selectedNoteKeys } = this . state
1122
1136
const sortBy = _ . get ( config , [ folderKey , 'sortBy' ] , config . sortBy . default )
1137
+ const sortDir = config . listDirection
1123
1138
const sortFunc =
1124
1139
sortBy === 'CREATED_AT'
1125
1140
? sortByCreatedAt
@@ -1129,6 +1144,7 @@ class NoteList extends React.Component {
1129
1144
const sortedNotes = location . pathname . match ( / \/ s t a r r e d | \/ t r a s h / )
1130
1145
? this . getNotes ( ) . sort ( sortFunc )
1131
1146
: this . sortByPin ( this . getNotes ( ) . sort ( sortFunc ) )
1147
+ if ( sortDir === 'DESCENDING' ) sortedNotes . reverse ( )
1132
1148
this . notes = notes = sortedNotes . filter ( note => {
1133
1149
// this is for the trash box
1134
1150
if ( note . isTrashed !== true || location . pathname === '/trashed' )
@@ -1241,6 +1257,30 @@ class NoteList extends React.Component {
1241
1257
</ select >
1242
1258
</ div >
1243
1259
< div styleName = 'control-button-area' >
1260
+ < button
1261
+ title = { i18n . __ ( 'Ascending Order' ) }
1262
+ styleName = {
1263
+ config . listDirection === 'ASCENDING'
1264
+ ? 'control-button--active'
1265
+ : 'control-button'
1266
+ }
1267
+ onClick = { e => this . handleListDirectionButtonClick ( e , 'ASCENDING' ) }
1268
+ >
1269
+ < img src = '../resources/icon/icon-up.svg' />
1270
+ </ button >
1271
+ < button
1272
+ title = { i18n . __ ( 'Descending Order' ) }
1273
+ styleName = {
1274
+ config . listDirection === 'DESCENDING'
1275
+ ? 'control-button--active'
1276
+ : 'control-button'
1277
+ }
1278
+ onClick = { e =>
1279
+ this . handleListDirectionButtonClick ( e , 'DESCENDING' )
1280
+ }
1281
+ >
1282
+ < img src = '../resources/icon/icon-down.svg' />
1283
+ </ button >
1244
1284
< button
1245
1285
title = { i18n . __ ( 'Default View' ) }
1246
1286
styleName = {
0 commit comments