diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-03-09 11:21:14 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-03-10 15:39:31 +0100 |
| commit | de735b7ced8bb1148a1f282d975745cfd9d13435 (patch) | |
| tree | dc74c80de7356f9bcfc58861a23896f3609b3f3d /gui/src/shared | |
| parent | 9f8cb65cb0bfbb20793819aa73f12f48259b666a (diff) | |
| download | mullvadvpn-de735b7ced8bb1148a1f282d975745cfd9d13435.tar.xz mullvadvpn-de735b7ced8bb1148a1f282d975745cfd9d13435.zip | |
Return undefined if window or webview is destroyed
Diffstat (limited to 'gui/src/shared')
| -rw-r--r-- | gui/src/shared/ipc-helpers.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gui/src/shared/ipc-helpers.ts b/gui/src/shared/ipc-helpers.ts index 59eee46459..8c3c851a80 100644 --- a/gui/src/shared/ipc-helpers.ts +++ b/gui/src/shared/ipc-helpers.ts @@ -4,7 +4,7 @@ import log from './logging'; type Handler<T, R> = (callback: (arg: T) => R) => void; type Sender<T, R> = (arg: T) => R; -type Notifier<T> = (webContents: WebContents, arg: T) => void; +type Notifier<T> = (webContents: WebContents | undefined, arg: T) => void; type Listener<T> = (callback: (arg: T) => void) => void; interface MainToRenderer<T> { @@ -152,8 +152,8 @@ export function notifyRenderer<T>(): MainToRenderer<T> { } function notifyRendererImpl<T>(event: string, _ipcMain: EIpcMain): Notifier<T> { - return (webContents: WebContents, value: T) => { - if (webContents.isDestroyed()) { + return (webContents, value) => { + if (webContents === undefined) { log.error(`sender(${event}): webContents is already destroyed!`); } else { webContents.send(event, value); |
