From 8c23fa675fde15856eb33643f191ccc494e091c4 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Fri, 20 Apr 2018 00:13:37 +0900
Subject: [PATCH] refs #244 Block changing account when loading timeline
---
src/renderer/components/TimelineSpace.vue | 2 ++
src/renderer/store/GlobalHeader.js | 13 +++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/renderer/components/TimelineSpace.vue b/src/renderer/components/TimelineSpace.vue
index 1dc14f0fe1..7578c10345 100644
--- a/src/renderer/components/TimelineSpace.vue
+++ b/src/renderer/components/TimelineSpace.vue
@@ -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 () {
diff --git a/src/renderer/store/GlobalHeader.js b/src/renderer/store/GlobalHeader.js
index 87fedb82bc..3e7dec2f4e 100644
--- a/src/renderer/store/GlobalHeader.js
+++ b/src/renderer/store/GlobalHeader.js
@@ -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`)
})