@@ -2,14 +2,15 @@ import { action, autorun, observable, toJS } from 'mobx';
2
2
import { SortParams } from 'types/state' ;
3
3
import { BalanceMode , Unit } from 'util/constants' ;
4
4
import { Store } from 'store' ;
5
- import { Channel } from 'store/models' ;
5
+ import { Channel , Swap } from 'store/models' ;
6
6
7
7
export interface PersistentSettings {
8
8
sidebarVisible : boolean ;
9
9
unit : Unit ;
10
10
balanceMode : BalanceMode ;
11
11
tourAutoShown : boolean ;
12
12
channelSort : SortParams < Channel > ;
13
+ historySort : SortParams < Swap > ;
13
14
}
14
15
15
16
export default class SettingsStore {
@@ -36,6 +37,12 @@ export default class SettingsStore {
36
37
descending : true ,
37
38
} ;
38
39
40
+ /** specifies the sorting field and direction for the channel list */
41
+ @observable historySort : SortParams < Swap > = {
42
+ field : 'lastUpdateTime' ,
43
+ descending : true ,
44
+ } ;
45
+
39
46
/** the chosen language */
40
47
@observable lang = 'en-US' ;
41
48
@@ -98,6 +105,17 @@ export default class SettingsStore {
98
105
this . _store . log . info ( 'reset channel list sort order' , toJS ( this . channelSort ) ) ;
99
106
}
100
107
108
+ /**
109
+ * Sets the sort field and direction that the swap history list should use
110
+ * @param field the swap field to sort by
111
+ * @param descending true of the order should be descending, otherwise false
112
+ */
113
+ @action . bound
114
+ setHistorySort ( field : SortParams < Swap > [ 'field' ] , descending : boolean ) {
115
+ this . historySort = { field, descending } ;
116
+ this . _store . log . info ( 'updated history list sort order' , toJS ( this . historySort ) ) ;
117
+ }
118
+
101
119
/**
102
120
* initialized the settings and auto-save when a setting is changed
103
121
*/
@@ -112,6 +130,7 @@ export default class SettingsStore {
112
130
balanceMode : this . balanceMode ,
113
131
tourAutoShown : this . tourAutoShown ,
114
132
channelSort : toJS ( this . channelSort ) ,
133
+ historySort : toJS ( this . historySort ) ,
115
134
} ;
116
135
this . _store . storage . set ( 'settings' , settings ) ;
117
136
this . _store . log . info ( 'saved settings to localStorage' , settings ) ;
@@ -133,6 +152,7 @@ export default class SettingsStore {
133
152
this . balanceMode = settings . balanceMode ;
134
153
this . tourAutoShown = settings . tourAutoShown ;
135
154
if ( settings . channelSort ) this . channelSort = settings . channelSort ;
155
+ if ( settings . historySort ) this . historySort = settings . historySort ;
136
156
this . _store . log . info ( 'loaded settings' , settings ) ;
137
157
}
138
158
0 commit comments