fix: Remove all screen picker listeners on listen to prevent leak

Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
This commit is contained in:
Jacob Schlecht 2026-04-19 12:02:16 -06:00
parent 403e069a22
commit 5ddd5a9343
2 changed files with 3 additions and 5 deletions

View File

@ -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({

View File

@ -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),