add handlers and setting for nightly release

This commit is contained in:
jeffvli
2026-02-05 23:45:32 -08:00
parent 65c215fa9c
commit cf663de2fc
11 changed files with 403 additions and 51 deletions
+1
View File
@@ -1,4 +1,5 @@
export * from './use-app-focus';
export * from './use-check-for-updates';
export * from './use-container-query';
export * from './use-fast-average-color';
export * from './use-hide-scrollbar';
@@ -0,0 +1,29 @@
import { useQuery } from '@tanstack/react-query';
import isElectron from 'is-electron';
import { useEffect, useState } from 'react';
const CHECK_FOR_UPDATES_INTERVAL_MS = 6 * 60 * 60 * 1000;
const utils = isElectron() ? window.api?.utils : null;
export const useCheckForUpdates = () => {
const [enablePeriodicCheck, setEnablePeriodicCheck] = useState(false);
// We want to skip the first check since it's already checked in the main process when the app is started
useEffect(() => {
const timer = setTimeout(() => setEnablePeriodicCheck(true), CHECK_FOR_UPDATES_INTERVAL_MS);
return () => clearTimeout(timer);
}, []);
const isEnabled =
enablePeriodicCheck &&
Boolean(isElectron() && utils?.checkForUpdates && !utils?.disableAutoUpdates?.());
return useQuery({
enabled: isEnabled,
queryFn: () => utils?.checkForUpdates?.(),
queryKey: ['app-check-for-updates'],
refetchInterval: CHECK_FOR_UPDATES_INTERVAL_MS,
refetchIntervalInBackground: true,
});
};