diff --git a/src/native/window.ts b/src/native/window.ts index dd7e298..50db9ad 100644 --- a/src/native/window.ts +++ b/src/native/window.ts @@ -197,9 +197,6 @@ export function createMainWindow() { .then((sources) => { // Shortcut for linux wayland. if (sources.length == 1) { - // Clear out the IPC listener - mainWindow.webContents.send("screenpicker", []); - // TODO: Get audio to work with wayland // See vencord for an implementation using a virtual microphone. callback({ diff --git a/src/world/window.ts b/src/world/window.ts index 7bb657b..9995b6d 100644 --- a/src/world/window.ts +++ b/src/world/window.ts @@ -16,7 +16,6 @@ contextBridge.exposeInMainWorld("native", { setBadgeCount: (count: number) => ipcRenderer.send("setBadgeCount", count), - // Wrapped in braces to return void onceScreenPicker: ( onScreenPick: ( sources: { @@ -27,7 +26,9 @@ contextBridge.exposeInMainWorld("native", { }[], ) => void, ) => { - ipcRenderer.once("screenPicker", (_, sources) => onScreenPick(sources)); + const eventName = "screenPicker"; + ipcRenderer.removeAllListeners(eventName); + ipcRenderer.once(eventName, (_, sources) => onScreenPick(sources)); }, screenPickerCallback: (idx: number, audio: boolean) => ipcRenderer.send("screenPickerCallback", idx, audio),