mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
feat: check for updates every 60 minutes
This commit is contained in:
parent
3f8a4407ef
commit
33e1de7748
@ -4,10 +4,13 @@ import { SyncIcon } from "@primer/octicons-react";
|
||||
import { Link } from "../link/link";
|
||||
import * as styles from "./header.css";
|
||||
import type { AppUpdaterEvent } from "@types";
|
||||
import { minutesToMilliseconds } from "date-fns";
|
||||
|
||||
export const releasesPageUrl =
|
||||
"https://github.com/hydralauncher/hydra/releases/latest";
|
||||
|
||||
const CHECK_FOR_UPDATES_INTERVAL = minutesToMilliseconds(60);
|
||||
|
||||
export function AutoUpdateSubHeader() {
|
||||
const [isReadyToInstall, setIsReadyToInstall] = useState(false);
|
||||
const [newVersion, setNewVersion] = useState<string | null>(null);
|
||||
@ -32,15 +35,24 @@ export function AutoUpdateSubHeader() {
|
||||
}
|
||||
);
|
||||
|
||||
window.electron.checkForUpdates().then((isAutoInstallAvailable) => {
|
||||
setIsAutoInstallAvailable(isAutoInstallAvailable);
|
||||
});
|
||||
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const checkInterval = setInterval(() => {
|
||||
window.electron.checkForUpdates().then((isAutoInstallAvailable) => {
|
||||
console.log("checking for updates");
|
||||
setIsAutoInstallAvailable(isAutoInstallAvailable);
|
||||
});
|
||||
}, CHECK_FOR_UPDATES_INTERVAL);
|
||||
|
||||
return () => {
|
||||
clearInterval(checkInterval);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!newVersion) return null;
|
||||
|
||||
if (!isAutoInstallAvailable) {
|
||||
|
Loading…
Reference in New Issue
Block a user