diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-07-23 13:39:34 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-07-23 13:39:34 +0200 |
| commit | c2acb4aff58b7b7f60a13ab05104910f70741e3c (patch) | |
| tree | bc8bcac2c7386aa2522c89223aba4471cfb27820 /gui/src/main | |
| parent | d0951f1f9ae8d0c6be9c4aa961a257c97ddbf4f5 (diff) | |
| parent | f5f870074496283521d6adcc80537a54e2168c8e (diff) | |
| download | mullvadvpn-c2acb4aff58b7b7f60a13ab05104910f70741e3c.tar.xz mullvadvpn-c2acb4aff58b7b7f60a13ab05104910f70741e3c.zip | |
Merge branch 'fix-linter-warnings'
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/account-data-cache.ts | 5 | ||||
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 17 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 52 | ||||
| -rw-r--r-- | gui/src/main/notification-controller.ts | 3 |
4 files changed, 33 insertions, 44 deletions
diff --git a/gui/src/main/account-data-cache.ts b/gui/src/main/account-data-cache.ts index a79a934537..d55b511feb 100644 --- a/gui/src/main/account-data-cache.ts +++ b/gui/src/main/account-data-cache.ts @@ -2,7 +2,6 @@ import { closeToExpiry, hasExpired } from '../shared/account-expiry'; import { AccountToken, IAccountData, VoucherResponse } from '../shared/daemon-rpc-types'; import { DateComponent, dateByAddingComponent } from '../shared/date-helper'; import log from '../shared/logging'; -import consumePromise from '../shared/promise'; import { Scheduler } from '../shared/scheduler'; import { InvalidAccountError } from './errors'; @@ -50,7 +49,7 @@ export default class AccountDataCache { // Only fetch if there's no fetch for this account number in progress. if (!this.performingFetch) { - consumePromise(this.performFetch(accountToken)); + void this.performFetch(accountToken); } } else if (watcher) { watcher.onFinish(); @@ -149,7 +148,7 @@ export default class AccountDataCache { private scheduleFetch(accountToken: AccountToken, delay: number) { this.fetchRetryScheduler.schedule(() => { - consumePromise(this.performFetch(accountToken)); + void this.performFetch(accountToken); }, delay); } diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 10159ad49e..28b8e651dc 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -54,7 +54,6 @@ import log from '../shared/logging'; import * as managementInterface from './management_interface/management_interface_grpc_pb'; import * as grpcTypes from './management_interface/management_interface_pb'; import { CommunicationError, InvalidAccountError } from './errors'; -import consumePromise from '../shared/promise'; const NETWORK_CALL_TIMEOUT = 10000; const CHANNEL_STATE_TIMEOUT = 1000 * 60 * 60; @@ -585,11 +584,9 @@ export class DaemonRpc { this.connectionObservers.forEach((observer) => observer.onClose()); this.isConnected = false; // Try and reconnect in case - consumePromise( - this.connect().catch((error) => { - log.error(`Failed to reconnect - ${error}`); - }), - ); + void this.connect().catch((error) => { + log.error(`Failed to reconnect - ${error}`); + }); this.setChannelCallback(currentState); } else if (!wasConnected && currentState === grpc.connectivityState.READY) { this.isConnected = true; @@ -632,11 +629,9 @@ export class DaemonRpc { this.isConnected = false; } if (!this.isConnected) { - consumePromise( - this.connect().catch((error) => { - log.error(`Failed to reconnect - ${error}`); - }), - ); + void this.connect().catch((error) => { + log.error(`Failed to reconnect - ${error}`); + }); } }, 3000); } diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 54ea32932f..a81324fd27 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -49,7 +49,6 @@ import { UnsupportedVersionNotificationProvider, UpdateAvailableNotificationProvider, } from '../shared/notifications/notification'; -import consumePromise from '../shared/promise'; import { Scheduler } from '../shared/scheduler'; import AccountDataCache from './account-data-cache'; import { getOpenAtLogin, setOpenAtLogin } from './autostart'; @@ -510,7 +509,7 @@ class ApplicationMain { // disable pinch to zoom if (this.windowController.webContents) { - consumePromise(this.windowController.webContents.setVisualZoomLevelLimits(1, 1)); + void this.windowController.webContents.setVisualZoomLevelLimits(1, 1); } } } @@ -583,7 +582,7 @@ class ApplicationMain { } // fetch the latest version info in background - consumePromise(this.fetchLatestVersion()); + void this.fetchLatestVersion(); // reset the reconnect backoff when connection established. this.reconnectBackoff.reset(); @@ -636,7 +635,7 @@ class ApplicationMain { }; private connectToDaemon() { - consumePromise(this.daemonRpc.connect()); + void this.daemonRpc.connect(); } private recoverFromBootstrapError(_error?: Error) { @@ -719,7 +718,7 @@ class ApplicationMain { private setTunnelState(newState: TunnelState) { this.tunnelState = newState; this.updateTrayIcon(newState, this.settings.blockWhenDisconnected); - consumePromise(this.updateLocation()); + void this.updateLocation(); if (process.platform === 'linux') { this.tray?.setContextMenu(this.createTrayContextMenu()); @@ -751,8 +750,8 @@ class ApplicationMain { this.updateAccountDataOnAccountChange(oldSettings.accountToken, newSettings.accountToken); if (oldSettings.accountToken !== newSettings.accountToken) { - consumePromise(this.updateAccountHistory()); - consumePromise(this.fetchWireguardKey()); + void this.updateAccountHistory(); + void this.fetchWireguardKey(); } if (oldSettings.showBetaReleases !== newSettings.showBetaReleases) { @@ -763,7 +762,7 @@ class ApplicationMain { IpcMainEventChannel.settings.notify(this.windowController.webContents, newSettings); if (windowsSplitTunneling) { - consumePromise(this.updateSplitTunnelingApplications(newSettings.splitTunnel.appsList)); + void this.updateSplitTunnelingApplications(newSettings.splitTunnel.appsList); } } @@ -1147,7 +1146,7 @@ class ApplicationMain { }); IpcMainEventChannel.guiSettings.handleSetUnpinnedWindow((unpinnedWindow: boolean) => { - consumePromise(this.setUnpinnedWindow(unpinnedWindow)); + void this.setUnpinnedWindow(unpinnedWindow); }); IpcMainEventChannel.guiSettings.handleSetPreferredLocale((locale: string) => { @@ -1174,7 +1173,7 @@ class ApplicationMain { IpcMainEventChannel.accountHistory.handleClear(async () => { await this.daemonRpc.clearAccountHistory(); - consumePromise(this.updateAccountHistory()); + void this.updateAccountHistory(); }); IpcMainEventChannel.wireguardKeys.handleGenerateKey(async () => { @@ -1367,7 +1366,7 @@ class ApplicationMain { if (this.autoConnectOnWireguardKeyEvent) { this.autoConnectOnWireguardKeyEvent = false; this.autoConnectFallbackScheduler.cancel(); - consumePromise(this.autoConnect()); + void this.autoConnect(); } } @@ -1484,7 +1483,7 @@ class ApplicationMain { private updateDaemonsAutoConnect() { const daemonAutoConnect = this.guiSettings.autoConnect && getOpenAtLogin(); if (daemonAutoConnect !== this.settings.autoConnect) { - consumePromise(this.daemonRpc.setAutoConnect(daemonAutoConnect)); + void this.daemonRpc.setAutoConnect(daemonAutoConnect); } } @@ -1598,19 +1597,16 @@ class ApplicationMain { } private async installDevTools() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const installer = require('electron-devtools-installer'); - const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS']; + const { default: installer, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = await import( + 'electron-devtools-installer' + ); const forceDownload = !!process.env.UPGRADE_EXTENSIONS; - for (const name of extensions) { - try { - await installer.default(installer[name], { - forceDownload, - loadExtensionOptions: { allowFileAccess: true }, - }); - } catch (e) { - log.info(`Error installing ${name} extension: ${e.message}`); - } + const options = { forceDownload, loadExtensionOptions: { allowFileAccess: true } }; + try { + await installer(REACT_DEVELOPER_TOOLS, options); + await installer(REDUX_DEVTOOLS, options); + } catch (e) { + log.info(`Error installing extension: ${e.message}`); } } @@ -1685,7 +1681,7 @@ class ApplicationMain { // make the window visible on all workspaces and prevent the icon from showing in the dock // and app switcher. if (this.guiSettings.unpinnedWindow) { - consumePromise(app.dock.show()); + void app.dock.show(); } else { appWindow.setVisibleOnAllWorkspaces(true); app.dock.hide(); @@ -1774,16 +1770,16 @@ class ApplicationMain { if (this.tunnelState.state === 'disconnected') { // Workaround: gRPC calls are sometimes delayed by a few seconds and setImmediate // mitigates this. https://github.com/grpc/grpc-node/issues/882 - setImmediate(() => consumePromise(this.daemonRpc.connectTunnel())); + setImmediate(() => void this.daemonRpc.connectTunnel()); } else { - setImmediate(() => consumePromise(this.daemonRpc.disconnectTunnel())); + setImmediate(() => void this.daemonRpc.disconnectTunnel()); } }, }, { label: messages.gettext('Reconnect'), enabled: this.tunnelState.state === 'connected' || this.tunnelState.state === 'connecting', - click: () => setImmediate(() => consumePromise(this.daemonRpc.reconnectTunnel())), + click: () => setImmediate(() => void this.daemonRpc.reconnectTunnel()), }, ]; diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index ca0e12888f..c4816e796a 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -13,7 +13,6 @@ import { SystemNotification, SystemNotificationProvider, } from '../shared/notifications/notification'; -import consumePromise from '../shared/promise'; interface NotificationControllerDelegate { openApp(): void; @@ -137,7 +136,7 @@ export default class NotificationController { private performAction(action?: NotificationAction) { if (action && action.type === 'open-url') { - consumePromise(this.notificationControllerDelegate.openLink(action.url, action.withAuth)); + void this.notificationControllerDelegate.openLink(action.url, action.withAuth); } } |
