Minor bug fixes and CI change.
This commit is contained in:
21
src/main/util/toRenderer.ts
Normal file
21
src/main/util/toRenderer.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { BrowserWindow } from "electron";
|
||||
import log from "electron-log/main";
|
||||
|
||||
const getMainWindow = (): Electron.BrowserWindow => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
return mainWindow;
|
||||
};
|
||||
|
||||
const sendIpcToRenderer = (ipcMessage: string, ...args: any[]): void => {
|
||||
const window = getMainWindow();
|
||||
if (window) {
|
||||
window.webContents.send(ipcMessage, ...args);
|
||||
} else {
|
||||
log.error(
|
||||
"Unable to find main window. Cannot send IPC message.",
|
||||
ipcMessage,
|
||||
args,
|
||||
);
|
||||
}
|
||||
};
|
||||
export { getMainWindow, sendIpcToRenderer };
|
||||
Reference in New Issue
Block a user