From 0751d6093fcf2751d39dcc5006a05b87dff52c9e Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Wed, 29 May 2024 22:36:37 +0100 Subject: [PATCH] fix: fixing memory leak on check-for-updates --- src/main/events/autoupdater/check-for-updates.ts | 9 ++++----- src/renderer/src/components/header/header.tsx | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/events/autoupdater/check-for-updates.ts b/src/main/events/autoupdater/check-for-updates.ts index b6487f47..a5d6e87b 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -10,24 +10,23 @@ const sendEvent = (event: AppUpdaterEvents) => { WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event); }; -const mockValuesForDebug = async () => { +const mockValuesForDebug = () => { sendEvent({ type: "update-available", info: { version: "1.3.0" } }); - // sendEvent({ type: "update-downloaded" }); }; const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => { autoUpdater - .addListener("update-available", (info: UpdateInfo) => { + .once("update-available", (info: UpdateInfo) => { sendEvent({ type: "update-available", info }); }) - .addListener("update-downloaded", () => { + .once("update-downloaded", () => { sendEvent({ type: "update-downloaded" }); }); if (app.isPackaged) { autoUpdater.checkForUpdates(); } else { - await mockValuesForDebug(); + mockValuesForDebug(); } }; diff --git a/src/renderer/src/components/header/header.tsx b/src/renderer/src/components/header/header.tsx index 31ada4cf..85dddb84 100644 --- a/src/renderer/src/components/header/header.tsx +++ b/src/renderer/src/components/header/header.tsx @@ -80,7 +80,7 @@ export function Header({ onSearch, onClear, search }: HeaderProps) { return () => { unsubscribe(); }; - }); + }, []); const focusInput = () => { setIsFocused(true);