From ef9942cf5f60f309a15c48f8383f02b6c118c872 Mon Sep 17 00:00:00 2001 From: Javier Guzman <906599+javierguzman@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:00:12 +0200 Subject: [PATCH] fix: remove properly usb when closing window --- src/main/index.ts | 1 + src/main/setup/configureUSB.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/index.ts b/src/main/index.ts index bb2e83a50..aa0abfa1e 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -48,6 +48,7 @@ app.on("activate", async () => { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (BrowserWindow.getAllWindows().length === 0) { + addUSBListeners(); createWindow(); } }); diff --git a/src/main/setup/configureUSB.ts b/src/main/setup/configureUSB.ts index 1ee389b00..ea38ac8e7 100644 --- a/src/main/setup/configureUSB.ts +++ b/src/main/setup/configureUSB.ts @@ -65,6 +65,7 @@ export const addUSBListeners = () => { export const removeUSBListeners = () => { webusb.removeEventListener("connect", onUSBConnect); webusb.removeEventListener("disconnect", onUSBDisconnect); + ipcMain.removeHandler("usb-devices"); }; export const getDevices = () => {