refs #244 Block changing account when loading timeline

This commit is contained in:
AkiraFukushima 2018-04-20 00:13:37 +09:00
parent e0c4953c2f
commit 8c23fa675f
2 changed files with 13 additions and 2 deletions

View File

@ -30,9 +30,11 @@ export default {
this.initialize()
.then(() => {
loading.close()
this.$store.commit('GlobalHeader/updateChanging', false)
})
.catch(() => {
loading.close()
this.$store.commit('GlobalHeader/updateChanging', false)
})
},
beforeDestroy () {

View File

@ -5,7 +5,8 @@ const GlobalHeader = {
namespaced: true,
state: {
defaultActive: '0',
accounts: []
accounts: [],
changing: false
},
mutations: {
changeDefaultActive (state, index) {
@ -13,6 +14,9 @@ const GlobalHeader = {
},
updateAccounts (state, accounts) {
state.accounts = accounts
},
updateChanging (state, value) {
state.changing = value
}
},
actions: {
@ -30,8 +34,13 @@ const GlobalHeader = {
})
})
},
watchShortcutEvents ({ commit }) {
watchShortcutEvents ({ state, commit }) {
ipcRenderer.on('change-account', (event, account) => {
if (state.changing) {
return null
}
// changing finish after loading
commit('updateChanging', true)
commit('changeDefaultActive', account.index.toString())
router.push(`/${account._id}/home`)
})