Skip to content

Commit

Permalink
Correctly calculate the remaining time till the next update check (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda authored Dec 9, 2023
1 parent 9cb7224 commit 7d574a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/settings/ServerUpdateChecker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const UPDATE_CHECK_INTERVAL = 1000 * 60 * 60 * 24; // 1 day
export const ServerUpdateChecker = () => {
const { t } = useTranslation();

const [lastUpdateCheck, setLastUpdateCheck] = useLocalStorage('lastAutomatedServerUpdateCheck', Date.now());
const [lastUpdateCheck, setLastUpdateCheck] = useLocalStorage('lastAutomatedServerUpdateCheck', 0);

const {
data: serverUpdateCheckData,
Expand All @@ -48,7 +48,8 @@ export const ServerUpdateChecker = () => {
};

useEffect(() => {
const remainingTimeTillNextUpdateCheck = Date.now() - lastUpdateCheck;
const remainingTimeTillNextUpdateCheck =
(UPDATE_CHECK_INTERVAL - (Date.now() - lastUpdateCheck)) % UPDATE_CHECK_INTERVAL;

let timeout: NodeJS.Timeout | undefined;
const scheduleUpdateCheck = (timeoutMS: number) => {
Expand Down

0 comments on commit 7d574a2

Please sign in to comment.