fix: missing first call on check for updates

This commit is contained in:
Zamitto 2025-01-10 20:41:31 -03:00
parent e4fefdedb6
commit 8f1acb48a0
2 changed files with 14 additions and 8 deletions

View File

@ -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();
}

View File

@ -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;