diff --git a/src/main/events/autoupdater/check-for-updates.ts b/src/main/events/autoupdater/check-for-updates.ts index 1dcc80f3..9a7c9d20 100644 --- a/src/main/events/autoupdater/check-for-updates.ts +++ b/src/main/events/autoupdater/check-for-updates.ts @@ -1,7 +1,7 @@ import type { AppUpdaterEvent } from "@types"; import { registerEvent } from "../register-event"; import updater, { UpdateInfo } from "electron-updater"; -import { WindowManager } from "@main/services"; +import { logger, WindowManager } from "@main/services"; import { app } from "electron"; import { publishNotificationUpdateReadyToInstall } from "@main/services/notifications"; @@ -36,7 +36,9 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => { if (app.isPackaged) { autoUpdater.autoDownload = isAutoInstallAvailable; - autoUpdater.checkForUpdates(); + autoUpdater.checkForUpdates().then((result) => { + logger.log(`Check for updates result: ${result}`); + }); } else if (sendEventsForDebug) { mockValuesForDebug(); } diff --git a/src/renderer/src/components/header/auto-update-sub-header.tsx b/src/renderer/src/components/header/auto-update-sub-header.tsx index cbba001e..5cf4d119 100644 --- a/src/renderer/src/components/header/auto-update-sub-header.tsx +++ b/src/renderer/src/components/header/auto-update-sub-header.tsx @@ -1,5 +1,5 @@ import { useTranslation } from "react-i18next"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { SyncIcon } from "@primer/octicons-react"; import { Link } from "../link/link"; import * as styles from "./header.css"; @@ -40,18 +40,22 @@ export function AutoUpdateSubHeader() { }; }, []); + const checkForUpdates = useCallback(() => { + window.electron.checkForUpdates().then((isAutoInstallAvailable) => { + setIsAutoInstallAvailable(isAutoInstallAvailable); + }); + }, []); + useEffect(() => { + checkForUpdates(); const checkInterval = setInterval(() => { - window.electron.checkForUpdates().then((isAutoInstallAvailable) => { - console.log("checking for updates"); - setIsAutoInstallAvailable(isAutoInstallAvailable); - }); + checkForUpdates(); }, CHECK_FOR_UPDATES_INTERVAL); return () => { clearInterval(checkInterval); }; - }, []); + }, [checkForUpdates]); if (!newVersion) return null;