diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-08-20 13:00:24 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-08-25 14:52:32 +0200 |
| commit | 356a01286b201a0919bc7fd7719387124b836ad9 (patch) | |
| tree | 6d234ab88113fdcc187ca3de24256334de949709 /gui/src | |
| parent | ea84ed8adf01cf53d5065076634aac7e9ba7b903 (diff) | |
| download | mullvadvpn-356a01286b201a0919bc7fd7719387124b836ad9.tar.xz mullvadvpn-356a01286b201a0919bc7fd7719387124b836ad9.zip | |
Reset navigation after being hidden for two minutes
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/index.ts | 27 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 2 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 3 |
3 files changed, 22 insertions, 10 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index aa49ff460d..769863fd72 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -226,6 +226,8 @@ class ApplicationMain { private autoConnectOnWireguardKeyEvent = false; private autoConnectFallbackScheduler = new Scheduler(); + private blurNavigationResetScheduler = new Scheduler(); + private rendererLog?: Logger; private translations: ITranslations = { locale: this.locale }; @@ -500,7 +502,6 @@ class ApplicationMain { this.installWindowCloseHandler(this.windowController); this.installTrayClickHandlers(); - this.installGenericFocusHandlers(this.windowController); const filePath = path.resolve(path.join(__dirname, '../renderer/index.html')); try { @@ -1045,6 +1046,10 @@ class ApplicationMain { private registerWindowListener(windowController: WindowController) { windowController.window?.on('focus', () => { + IpcMainEventChannel.windowFocus.notify(windowController.webContents, true); + + this.blurNavigationResetScheduler.cancel(); + // cancel notifications when window appears this.notificationController.cancelPendingNotifications(); @@ -1058,9 +1063,20 @@ class ApplicationMain { }); windowController.window?.on('blur', () => { + IpcMainEventChannel.windowFocus.notify(windowController.webContents, false); + // ensure notification guard is reset this.notificationController.resetTunnelStateAnnouncements(); }); + + // Use hide instead of blur to prevent the navigation reset from happening when bluring an + // unpinned window. + windowController.window?.on('hide', () => { + this.blurNavigationResetScheduler.schedule( + () => IpcMainEventChannel.navigation.notifyReset(windowController.webContents), + 120_000, + ); + }); } private registerIpcListeners() { @@ -1942,15 +1958,6 @@ class ApplicationMain { } } - private installGenericFocusHandlers(windowController: WindowController) { - windowController.window?.on('focus', () => { - IpcMainEventChannel.windowFocus.notify(windowController.webContents, true); - }); - windowController.window?.on('blur', () => { - IpcMainEventChannel.windowFocus.notify(windowController.webContents, false); - }); - } - private shouldShowWindowOnStart(): boolean { switch (process.platform) { case 'win32': diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 277227eac7..54f843a6e0 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -205,6 +205,8 @@ export default class AppRenderer { this.reduxActions.userInterface.setWindowFocused(focus); }); + IpcRendererEventChannel.navigation.listenReset(() => this.history.dismiss(true)); + // Request the initial state from the main process const initialState = IpcRendererEventChannel.state.get(); diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index 1053ecf4e8..93f6b66b92 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -105,6 +105,9 @@ export const ipcSchema = { windowFocus: { '': notifyRenderer<boolean>(), }, + navigation: { + reset: notifyRenderer<void>(), + }, daemon: { connected: notifyRenderer<void>(), disconnected: notifyRenderer<void>(), |
