diff --git a/src/lib/native/NativeTree.ts b/src/lib/native/NativeTree.ts index c291cfc8f1..3534bba030 100644 --- a/src/lib/native/NativeTree.ts +++ b/src/lib/native/NativeTree.ts @@ -21,7 +21,7 @@ export default class NativeTree extends CachingAdapter implements BulkImportReso const {value: tree} = await Storage.get({key: `bookmarks[${this.accountId}].tree`}) const {value: highestId} = await Storage.get({key: `bookmarks[${this.accountId}].highestId`}) if (tree) { - const oldHash = this.bookmarksCache && await this.bookmarksCache.hash(true) + const oldHash = this.bookmarksCache && await this.bookmarksCache.clone(false).hash(true) this.bookmarksCache = Folder.hydrate(JSON.parse(tree)) const newHash = await this.bookmarksCache.hash(true) this.highestId = parseInt(highestId) diff --git a/src/ui/store/definitions.js b/src/ui/store/definitions.js index f17390657b..def17e734e 100644 --- a/src/ui/store/definitions.js +++ b/src/ui/store/definitions.js @@ -6,6 +6,7 @@ export const actions = { LOAD_ACCOUNTS: 'LOAD_ACCOUNTS', SELECT_ACCOUNT: 'SELECT_ACCOUNT', LOAD_TREE: 'LOAD_TREE', + LOAD_TREE_FROM_DISK: 'LOAD_TREE_FROM_DISK', CREATE_BOOKMARK: 'CREATE_BOOKMARK', EDIT_BOOKMARK: 'EDIT_BOOKMARK', DELETE_BOOKMARK: 'DELETE_BOOKMARK', diff --git a/src/ui/store/native/actions.js b/src/ui/store/native/actions.js index 9131c18eb1..470aefb7a6 100644 --- a/src/ui/store/native/actions.js +++ b/src/ui/store/native/actions.js @@ -33,6 +33,19 @@ export const actionsDefinition = { const rootFolder = await tree.getBookmarksTree(true) await commit(mutations.LOAD_TREE, rootFolder) }, + async [actions.LOAD_TREE_FROM_DISK]({ commit, dispatch, state }, id) { + const account = await Account.get(id) + if (account.syncing) { + return + } + const tree = await account.getResource() + const changed = await tree.load() + const rootFolder = await tree.getBookmarksTree(true) + await commit(mutations.LOAD_TREE, rootFolder) + if (changed) { + await dispatch(actions.TRIGGER_SYNC, id) + } + }, async [actions.CREATE_BOOKMARK]({commit}, {accountId, bookmark}) { const account = await Account.get(accountId) const tree = await account.getResource() diff --git a/src/ui/views/native/Tree.vue b/src/ui/views/native/Tree.vue index c90c160acd..b1ee24af2c 100644 --- a/src/ui/views/native/Tree.vue +++ b/src/ui/views/native/Tree.vue @@ -431,6 +431,7 @@ export default { }, mounted() { this.$store.dispatch(actions.LOAD_TREE, this.$route.params.accountId) + App.addListener('resume', () => this.$store.dispatch(actions.LOAD_TREE_FROM_DISK, this.$route.params.accountId)) }, backButton() { this.goBack()