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) => {