summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2017-12-04 15:12:05 +0100
committerAndrej Mihajlov <and@mullvad.net>2017-12-06 13:36:25 +0100
commit75057e7c4017312546281e50f8fb748ce643ec2f (patch)
treea374fd92642f2f0dad70df1b083dde46041ecb4a /app
parent25a21e825ef443997751f1109575573809f4d707 (diff)
downloadmullvadvpn-75057e7c4017312546281e50f8fb748ce643ec2f.tar.xz
mullvadvpn-75057e7c4017312546281e50f8fb748ce643ec2f.zip
Convert Backend.removeAccountFromHistory() and Backend._updateAccountHistory() to async
Diffstat (limited to 'app')
-rw-r--r--app/lib/backend.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 778997fa38..a9526b73f7 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -353,24 +353,26 @@ export class Backend {
}
}
- removeAccountFromHistory(accountToken: AccountToken): Promise<void> {
- return this._ensureAuthenticated()
- .then(() => this._ipc.removeAccountFromHistory(accountToken))
- .then(() => this._updateAccountHistory())
- .catch(e => {
- log.error('Failed to remove account token from history', e.message);
- });
+ async removeAccountFromHistory(accountToken: AccountToken): Promise<void> {
+ try {
+ await this._ensureAuthenticated();
+ await this._ipc.removeAccountFromHistory(accountToken);
+ await this._updateAccountHistory();
+ } catch(e) {
+ log.error('Failed to remove account token from history', e.message);
+ }
}
- _updateAccountHistory(): Promise<void> {
- return this._ensureAuthenticated()
- .then(() => this._ipc.getAccountHistory())
- .then((accountHistory) => {
- this._store.dispatch(
- accountActions.updateAccountHistory(accountHistory)
- );
- })
- .catch(e => log.info('Failed to fetch account history,', e.message));
+ async _updateAccountHistory(): Promise<void> {
+ try {
+ await this._ensureAuthenticated();
+ const accountHistory = await this._ipc.getAccountHistory();
+ this._store.dispatch(
+ accountActions.updateAccountHistory(accountHistory)
+ );
+ } catch(e) {
+ log.info('Failed to fetch account history,', e.message);
+ }
}
/**