From fbc8d814cd3d7c08f1bd269f5ea1e15e05593489 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 16 May 2018 00:19:07 +0900
Subject: [PATCH] refs #274 Update icon when user add a new account
---
src/main/index.js | 6 ++++++
src/renderer/store/GlobalHeader.js | 13 ++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/main/index.js b/src/main/index.js
index 3cbafe46..13d71fe6 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -374,6 +374,12 @@ ipcMain.on('backward-account', (event, acct) => {
ipcMain.on('refresh-accounts', (event, _) => {
const account = new Account(accountDB)
account.refreshAccounts()
+ .then((accounts) => {
+ event.sender.send('response-refresh-accounts', accounts)
+ })
+ .catch((err) => {
+ event.sender.send('error-refresh-accounts', err)
+ })
})
// streaming
diff --git a/src/renderer/store/GlobalHeader.js b/src/renderer/store/GlobalHeader.js
index 60da8bc7..aa5c4f01 100644
--- a/src/renderer/store/GlobalHeader.js
+++ b/src/renderer/store/GlobalHeader.js
@@ -37,7 +37,18 @@ const GlobalHeader = {
},
// Fetch account informations and save current state when GlobalHeader is displayed
refreshAccounts ({ commit, state }) {
- ipcRenderer.send('refresh-accounts')
+ return new Promise((resolve, reject) => {
+ ipcRenderer.send('refresh-accounts')
+ ipcRenderer.once('error-refresh-accounts', (event, err) => {
+ ipcRenderer.removeAllListeners('response-refresh-accounts')
+ reject(err)
+ })
+ ipcRenderer.once('response-refresh-accounts', (event, accounts) => {
+ ipcRenderer.removeAllListeners('error-refresh-accounts')
+ commit('updateAccounts', accounts)
+ resolve(accounts)
+ })
+ })
},
watchShortcutEvents ({ state, commit, rootState }) {
ipcRenderer.on('change-account', (event, account) => {