summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-02-19 19:31:35 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-02-21 14:18:21 +0100
commit6ad3b7b22e21288e4fa6bea6342f8a63e18552ee (patch)
treed1be7c8a127d02ab724df7b9b6a4eb8b4ec356e4 /gui/src/main
parent7081c2ffc2c2d228131588cf83d023a78a647c3a (diff)
downloadmullvadvpn-6ad3b7b22e21288e4fa6bea6342f8a63e18552ee.tar.xz
mullvadvpn-6ad3b7b22e21288e4fa6bea6342f8a63e18552ee.zip
Fix linter problems caused by @typescript-eslint/no-floating-promises
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/account-data-cache.ts5
-rw-r--r--gui/src/main/daemon-rpc.ts6
-rw-r--r--gui/src/main/index.ts21
-rw-r--r--gui/src/main/notification-controller.ts3
4 files changed, 21 insertions, 14 deletions
diff --git a/gui/src/main/account-data-cache.ts b/gui/src/main/account-data-cache.ts
index 0c68f38729..58c6d41dbd 100644
--- a/gui/src/main/account-data-cache.ts
+++ b/gui/src/main/account-data-cache.ts
@@ -1,5 +1,6 @@
import log from 'electron-log';
import { AccountToken, IAccountData } from '../shared/daemon-rpc-types';
+import consumePromise from '../shared/promise';
export enum AccountFetchRetryAction {
stop,
@@ -37,7 +38,7 @@ export default class AccountDataCache {
this.watchers.push(watcher);
}
- this.performFetch(accountToken);
+ consumePromise(this.performFetch(accountToken));
} else if (watcher) {
watcher.onFinish();
}
@@ -107,7 +108,7 @@ export default class AccountDataCache {
this.fetchRetryTimeout = global.setTimeout(() => {
this.fetchRetryTimeout = undefined;
- this.performFetch(accountToken);
+ consumePromise(this.performFetch(accountToken));
}, delay);
}
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index f593fa2271..00201f7505 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -392,8 +392,8 @@ const NETWORK_CALL_TIMEOUT = 10000;
export class DaemonRpc {
private transport = new JsonRpcClient(new SocketTransport());
- public connect(connectionParams: { path: string }) {
- this.transport.connect(connectionParams);
+ public connect(connectionParams: { path: string }): Promise<void> {
+ return this.transport.connect(connectionParams);
}
public disconnect() {
@@ -555,7 +555,7 @@ export class DaemonRpc {
listener: SubscriptionListener<DaemonEvent>,
): Promise<void> {
if (listener.subscriptionId) {
- return await this.transport.unsubscribe('daemon_event', listener.subscriptionId);
+ return this.transport.unsubscribe('daemon_event', listener.subscriptionId);
}
}
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 6d146eb418..3b13231e69 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -34,6 +34,7 @@ import {
getRendererLogFile,
setupLogging,
} from '../shared/logging';
+import consumePromise from '../shared/promise';
import AccountDataCache, { AccountFetchRetryAction } from './account-data-cache';
import { getOpenAtLogin, setOpenAtLogin } from './autostart';
import {
@@ -379,7 +380,11 @@ class ApplicationMain {
windowController.show();
}
- window.loadFile(path.resolve(path.join(__dirname, '../renderer/index.html')));
+ try {
+ await window.loadFile(path.resolve(path.join(__dirname, '../renderer/index.html')));
+ } catch (error) {
+ log.error(`Failed to load index file: ${error.message}`);
+ }
};
private onDaemonConnected = async () => {
@@ -444,7 +449,7 @@ class ApplicationMain {
}
// fetch the latest version info in background
- this.fetchLatestVersion();
+ consumePromise(this.fetchLatestVersion());
// notify user about inconsistent version
if (
@@ -502,7 +507,7 @@ class ApplicationMain {
};
private connectToDaemon() {
- this.daemonRpc.connect({ path: DAEMON_RPC_PATH });
+ consumePromise(this.daemonRpc.connect({ path: DAEMON_RPC_PATH }));
}
private reconnectToDaemon() {
@@ -585,7 +590,7 @@ class ApplicationMain {
private setTunnelState(newState: TunnelState) {
this.tunnelState = newState;
this.updateTrayIcon(newState, this.settings.blockWhenDisconnected);
- this.updateLocation();
+ consumePromise(this.updateLocation());
if (!this.shouldSuppressNotifications(false)) {
this.notificationController.notifyTunnelState(newState);
@@ -610,8 +615,8 @@ class ApplicationMain {
this.updateAccountDataOnAccountChange(oldSettings.accountToken, newSettings.accountToken);
if (oldSettings.accountToken !== newSettings.accountToken) {
- this.updateAccountHistory();
- this.fetchWireguardKey();
+ consumePromise(this.updateAccountHistory());
+ consumePromise(this.fetchWireguardKey());
}
if (this.windowController) {
@@ -975,7 +980,7 @@ class ApplicationMain {
IpcMainEventChannel.accountHistory.handleRemoveItem(async (token: AccountToken) => {
await this.daemonRpc.removeAccountFromHistory(token);
- this.updateAccountHistory();
+ consumePromise(this.updateAccountHistory());
});
IpcMainEventChannel.wireguardKeys.handleGenerateKey(async () => {
@@ -1183,7 +1188,7 @@ class ApplicationMain {
private updateDaemonsAutoConnect() {
const daemonAutoConnect = this.guiSettings.autoConnect && getOpenAtLogin();
if (daemonAutoConnect !== this.settings.autoConnect) {
- this.daemonRpc.setAutoConnect(daemonAutoConnect);
+ consumePromise(this.daemonRpc.setAutoConnect(daemonAutoConnect));
}
}
diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts
index 69c0f9ec30..4c542db3ea 100644
--- a/gui/src/main/notification-controller.ts
+++ b/gui/src/main/notification-controller.ts
@@ -6,6 +6,7 @@ import config from '../config.json';
import AccountExpiry from '../shared/account-expiry';
import { TunnelState } from '../shared/daemon-rpc-types';
import { messages } from '../shared/gettext';
+import consumePromise from '../shared/promise';
export default class NotificationController {
private lastTunnelStateAnnouncement?: { body: string; notification: Notification };
@@ -140,7 +141,7 @@ export default class NotificationController {
});
notification.on('click', () => {
- shell.openExternal(config.links.download);
+ consumePromise(shell.openExternal(config.links.download));
});
this.scheduleNotification(notification);