diff --git a/src/main/setup/configureIPCs.ts b/src/main/setup/configureIPCs.ts index 7b8584fdf..6a5dcf2eb 100644 --- a/src/main/setup/configureIPCs.ts +++ b/src/main/setup/configureIPCs.ts @@ -9,7 +9,8 @@ const configureIPCs = () => { const globalRecording = GlobalRecording.getInstance(); const window = Window.getWindow(); - ipcMain.on("start-recording", (event, arg) => { + ipcMain.removeHandler("start-recording"); + ipcMain.on("start-recording", () => { console.log("start-recording"); globalRecording.setRecording(true); uIOhook.on("keydown", sendkeyDown); @@ -17,7 +18,8 @@ const configureIPCs = () => { uIOhook.start(); }); - ipcMain.on("stop-recording", (event, arg) => { + ipcMain.removeHandler("stop-recording"); + ipcMain.on("stop-recording", () => { console.log("stop-recording"); globalRecording.setRecording(false); uIOhook.off("keydown", sendkeyDown); @@ -25,25 +27,31 @@ const configureIPCs = () => { uIOhook.stop(); }); + ipcMain.removeHandler("list-drives"); ipcMain.handle("list-drives", async (event, options) => { const data = listDrivesHandler(event, options); return data; }); + + ipcMain.removeHandler("open-dialog"); ipcMain.handle("open-dialog", async (event, options) => { const data = await dialog.showOpenDialog(window, options); return data; }); + ipcMain.removeHandler("save-dialog"); ipcMain.handle("save-dialog", async (event, options) => { const data = dialog.showSaveDialogSync(window, options); return data; }); - ipcMain.handle("is-devtools-opened", async (event, someArgument) => { + ipcMain.removeHandler("is-devtools-opened"); + ipcMain.handle("is-devtools-opened", async () => { const data = window.webContents.isDevToolsOpened(); return data; }); + ipcMain.removeHandler("manage-devtools"); ipcMain.handle("manage-devtools", (event, action) => { if (action === true) { window.webContents.openDevTools(); @@ -52,16 +60,20 @@ const configureIPCs = () => { } }); + ipcMain.removeHandler("get-userPath"); ipcMain.handle("get-userPath", (event, path) => app.getPath(path)); + ipcMain.removeHandler("openExternal"); ipcMain.handle("openExternal", (event, URI) => shell.openExternal(URI)); - ipcMain.handle("get-Locale", (event, someArgument) => { + ipcMain.removeHandler("get-Locale"); + ipcMain.handle("get-Locale", () => { const locale = app.getLocale(); return locale; }); - ipcMain.handle("get-NativeTheme", (event, someArgument) => nativeTheme.shouldUseDarkColors); + ipcMain.removeHandler("get-NativeTheme"); + ipcMain.handle("get-NativeTheme", () => nativeTheme.shouldUseDarkColors); }; export default configureIPCs; diff --git a/src/main/utils/listDrivesHandler.ts b/src/main/utils/listDrivesHandler.ts index 46ed278c8..1fb14fcd5 100644 --- a/src/main/utils/listDrivesHandler.ts +++ b/src/main/utils/listDrivesHandler.ts @@ -1,6 +1,8 @@ -const drivelist = require("drivelist"); import delay from "./delay"; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const drivelist = require("drivelist"); + const listDrivesHandler = async (_event: any, _someArgument: any) => { let drives; let result: undefined | any; @@ -10,7 +12,7 @@ const listDrivesHandler = async (_event: any, _someArgument: any) => { console.log("drive info", drive.description, drive.mountpoints); if (drive.description.includes("RPI RP2") || drive.description.includes("RPI-RP2")) { while (drive.mountpoints[0] === undefined || drive.mountpoints.length === 0) { - delay(100); + await delay(100); drives = await drivelist.list(); result = drives[index].mountpoints[0]; console.log(result);