fix: fixing memory leak on check-for-updates

This commit is contained in:
Chubby Granny Chaser 2024-05-29 22:36:37 +01:00
parent 34a44e7fa9
commit 0751d6093f
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View file

@ -10,24 +10,23 @@ const sendEvent = (event: AppUpdaterEvents) => {
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event); WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
}; };
const mockValuesForDebug = async () => { const mockValuesForDebug = () => {
sendEvent({ type: "update-available", info: { version: "1.3.0" } }); sendEvent({ type: "update-available", info: { version: "1.3.0" } });
// sendEvent({ type: "update-downloaded" });
}; };
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => { const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
autoUpdater autoUpdater
.addListener("update-available", (info: UpdateInfo) => { .once("update-available", (info: UpdateInfo) => {
sendEvent({ type: "update-available", info }); sendEvent({ type: "update-available", info });
}) })
.addListener("update-downloaded", () => { .once("update-downloaded", () => {
sendEvent({ type: "update-downloaded" }); sendEvent({ type: "update-downloaded" });
}); });
if (app.isPackaged) { if (app.isPackaged) {
autoUpdater.checkForUpdates(); autoUpdater.checkForUpdates();
} else { } else {
await mockValuesForDebug(); mockValuesForDebug();
} }
}; };

View file

@ -80,7 +80,7 @@ export function Header({ onSearch, onClear, search }: HeaderProps) {
return () => { return () => {
unsubscribe(); unsubscribe();
}; };
}); }, []);
const focusInput = () => { const focusInput = () => {
setIsFocused(true); setIsFocused(true);