fix: Remove all screen picker listeners on listen to prevent leak
Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
This commit is contained in:
parent
403e069a22
commit
5ddd5a9343
|
|
@ -197,9 +197,6 @@ export function createMainWindow() {
|
||||||
.then((sources) => {
|
.then((sources) => {
|
||||||
// Shortcut for linux wayland.
|
// Shortcut for linux wayland.
|
||||||
if (sources.length == 1) {
|
if (sources.length == 1) {
|
||||||
// Clear out the IPC listener
|
|
||||||
mainWindow.webContents.send("screenpicker", []);
|
|
||||||
|
|
||||||
// TODO: Get audio to work with wayland
|
// TODO: Get audio to work with wayland
|
||||||
// See vencord for an implementation using a virtual microphone.
|
// See vencord for an implementation using a virtual microphone.
|
||||||
callback({
|
callback({
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ contextBridge.exposeInMainWorld("native", {
|
||||||
|
|
||||||
setBadgeCount: (count: number) => ipcRenderer.send("setBadgeCount", count),
|
setBadgeCount: (count: number) => ipcRenderer.send("setBadgeCount", count),
|
||||||
|
|
||||||
// Wrapped in braces to return void
|
|
||||||
onceScreenPicker: (
|
onceScreenPicker: (
|
||||||
onScreenPick: (
|
onScreenPick: (
|
||||||
sources: {
|
sources: {
|
||||||
|
|
@ -27,7 +26,9 @@ contextBridge.exposeInMainWorld("native", {
|
||||||
}[],
|
}[],
|
||||||
) => void,
|
) => void,
|
||||||
) => {
|
) => {
|
||||||
ipcRenderer.once("screenPicker", (_, sources) => onScreenPick(sources));
|
const eventName = "screenPicker";
|
||||||
|
ipcRenderer.removeAllListeners(eventName);
|
||||||
|
ipcRenderer.once(eventName, (_, sources) => onScreenPick(sources));
|
||||||
},
|
},
|
||||||
screenPickerCallback: (idx: number, audio: boolean) =>
|
screenPickerCallback: (idx: number, audio: boolean) =>
|
||||||
ipcRenderer.send("screenPickerCallback", idx, audio),
|
ipcRenderer.send("screenPickerCallback", idx, audio),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue