Skip to content

Commit 954252b

Browse files
committed
[native] enh: Remember sort option & sort folders first
fixes #1346 Signed-off-by: Marcel Klehr <[email protected]>
1 parent f2b3ba4 commit 954252b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/ui/store/definitions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const actions = {
3636
REQUEST_NETWORK_PERMISSIONS: 'REQUEST_NETWORK_PERMISSIONS',
3737
COUNT_BOOKMARK_CLICK: 'COUNT_BOOKMARK_CLICK',
3838
REQUEST_HISTORY_PERMISSIONS: 'REQUEST_HISTORY_PERMISSIONS',
39+
SET_SORTBY: 'SET_SORTBY',
3940
}
4041

4142
export const mutations = {

src/ui/store/native/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,9 @@ export const actionsDefinition = {
265265
},
266266
async [actions.STOP_LOGIN_FLOW]({commit}) {
267267
commit(mutations.SET_LOGIN_FLOW_STATE, false)
268+
},
269+
async [actions.SET_SORTBY]({state}, {accountId, sortBy}) {
270+
const account = await Account.get(accountId)
271+
await account.setData({...account.getData(), sortBy})
268272
}
269273
}

src/ui/views/native/Tree.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ export default {
392392
if (item.url) {
393393
return new URL(item.url).hostname
394394
} else {
395-
return '0' // folders to the top
395+
return '0000000' // folders to the top
396396
}
397397
}
398-
return item[this.sortBy].toLowerCase()
398+
return item.type === 'folder' ? '0000000' : item[this.sortBy].toLowerCase()
399399
}])
400400
} else {
401401
return items
@@ -421,6 +421,7 @@ export default {
421421
watch: {
422422
async $route() {
423423
await this.$store.dispatch(actions.LOAD_TREE, this.$route.params.accountId)
424+
this.sortBy = this.$store.state.accounts[this.id].data.sortBy || 'index'
424425
},
425426
async syncing(current, previous) {
426427
if (!current && previous) {
@@ -433,9 +434,13 @@ export default {
433434
await this.$store.dispatch(actions.LOAD_TREE, this.$route.params.accountId)
434435
}
435436
},
437+
async sortBy(current) {
438+
await this.$store.dispatch(actions.SET_SORTBY, {accountId: this.$route.params.accountId, sortBy: current})
439+
}
436440
},
437441
mounted() {
438442
this.$store.dispatch(actions.LOAD_TREE, this.$route.params.accountId)
443+
this.sortBy = this.$store.state.accounts[this.id].data.sortBy || 'index'
439444
App.addListener('resume', () => this.$store.dispatch(actions.LOAD_TREE_FROM_DISK, this.$route.params.accountId))
440445
},
441446
backButton() {

0 commit comments

Comments
 (0)