Skip to content

Commit 167fef2

Browse files
committed
[native] feat(search): Remember last used folder across app starts
fixes #1283 Signed-off-by: Marcel Klehr <[email protected]>
1 parent 382edc1 commit 167fef2

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/ui/components/native/DialogChooseFolder.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</template>
5454

5555
<script>
56-
import { actions, mutations } from '../../store/definitions'
56+
import { actions} from '../../store/definitions'
5757
import { Folder } from '../../../lib/Tree'
5858
5959
export default {
@@ -126,7 +126,7 @@ export default {
126126
})
127127
},
128128
onSave() {
129-
this.$store.commit(mutations.SET_LAST_FOLDER, {folderId: this.selectedFolder, accountId: this.$route.params.accountId})
129+
this.$store.dispatch(actions.SET_LAST_FOLDER, {folderId: this.selectedFolder, accountId: this.$route.params.accountId})
130130
this.$emit('update:display', false)
131131
this.$emit('input', this.selectedFolder)
132132
}

src/ui/store/definitions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const actions = {
3939
COUNT_BOOKMARK_CLICK: 'COUNT_BOOKMARK_CLICK',
4040
REQUEST_HISTORY_PERMISSIONS: 'REQUEST_HISTORY_PERMISSIONS',
4141
SET_SORTBY: 'SET_SORTBY',
42+
SET_LAST_FOLDER: 'SET_LAST_FOLDER',
4243
}
4344

4445
export const mutations = {

src/ui/store/native/actions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Share } from '@capacitor/share'
99
import Html from '../../../lib/serializers/Html'
1010
import { Bookmark, Folder } from '../../../lib/Tree'
1111
import { Browser } from '@capacitor/browser'
12+
import NativeAccountStorage from '../../../lib/native/NativeAccountStorage'
1213

1314
export const actionsDefinition = {
1415
async [actions.LOAD_ACCOUNTS]({ commit, dispatch, state }) {
@@ -25,6 +26,10 @@ export const actionsDefinition = {
2526
})
2627
)
2728
await commit(mutations.LOAD_ACCOUNTS, accounts)
29+
const lastFolders = await NativeAccountStorage.getEntry('lastFolders', {})
30+
await Promise.all(Object.entries(lastFolders).map(async([accountId, folderId]) => {
31+
await commit(mutations.SET_LAST_FOLDER, {accountId, folderId})
32+
}))
2833
commit(mutations.LOADING_END, 'accounts')
2934
},
3035
async [actions.LOAD_TREE]({ commit, dispatch, state }, id) {
@@ -293,5 +298,12 @@ export const actionsDefinition = {
293298
async [actions.SET_SORTBY]({state}, {accountId, sortBy}) {
294299
const account = await Account.get(accountId)
295300
await account.setData({ sortBy })
301+
},
302+
async [actions.SET_LAST_FOLDER]({commit}, {accountId, folderId}) {
303+
await NativeAccountStorage.changeEntry('lastFolders', (lastFolders) => {
304+
lastFolders[accountId] = folderId
305+
return lastFolders
306+
}, {})
307+
await commit(mutations.SET_LAST_FOLDER, {accountId, folderId})
296308
}
297309
}

src/ui/store/native/mutations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Vue from 'vue'
22
import { mutations } from '../definitions'
3+
import NativeAccountStorage from '../../../lib/native/NativeAccountStorage'
34

45
export const mutationsDefinition = {
56
[mutations.SET_LOCKED](state, locked) {

0 commit comments

Comments
 (0)