From f928d59208bb3ea52cd660f19324031679f62baf Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 9 May 2023 09:23:01 +0100 Subject: [PATCH] Null guard global mainWindow better (#948) --- src/ipc.ts | 2 +- src/seshat.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipc.ts b/src/ipc.ts index 8479e75..3845827 100644 --- a/src/ipc.ts +++ b/src/ipc.ts @@ -253,7 +253,7 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) { return; } - global.mainWindow.webContents.send("ipcReply", { + global.mainWindow?.webContents.send("ipcReply", { id: payload.id, reply: ret, }); diff --git a/src/seshat.ts b/src/seshat.ts index 45ec810..9ae970c 100644 --- a/src/seshat.ts +++ b/src/seshat.ts @@ -304,14 +304,14 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise break; default: - global.mainWindow.webContents.send("seshatReply", { + global.mainWindow?.webContents.send("seshatReply", { id: payload.id, error: "Unknown IPC Call: " + payload.name, }); return; } - global.mainWindow.webContents.send("seshatReply", { + global.mainWindow?.webContents.send("seshatReply", { id: payload.id, reply: ret, });