Skip to content

Commit

Permalink
fix(Account#setData): re-init in actions if localRoot is changed
Browse files Browse the repository at this point in the history
instead of in Account#setData

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Dec 31, 2023
1 parent 4e06ebb commit e05cf0a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/lib/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ export default class Account {
}

async setData(data:IAccountData):Promise<void> {
if (this.getData().localRoot !== data.localRoot) {
this.init()
}
await this.storage.setAccountData(data, null)
this.server.setData(data)
}
Expand Down
4 changes: 4 additions & 0 deletions src/ui/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export const actionsDefinition = {
},
async [actions.STORE_ACCOUNT]({ commit, dispatch, state }, { id,data }) {
const account = await Account.get(id)
const oldData = account.getData()
await account.setData(data)
if (oldData.localRoot !== data.localRoot) {
await account.init()
}
commit(mutations.STORE_ACCOUNT_DATA, {id, data})
},
async [actions.TRIGGER_SYNC]({ commit, dispatch, state }, accountId) {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/store/native/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ export const actionsDefinition = {
},
async [actions.STORE_ACCOUNT]({ commit, dispatch, state }, { id,data }) {
const account = await Account.get(id)
const oldData = account.getData()
await account.setData(data)
if (oldData.localRoot !== data.localRoot) {
await account.init()
}
commit(mutations.STORE_ACCOUNT_DATA, {id, data})
},
async [actions.TRIGGER_SYNC]({ commit, dispatch, state }, accountId) {
Expand Down

0 comments on commit e05cf0a

Please sign in to comment.