Correctly calculate the remaining time till the next update check (#491)
This commit is contained in:
@@ -23,7 +23,7 @@ const UPDATE_CHECK_INTERVAL = 1000 * 60 * 60 * 24; // 1 day
|
|||||||
export const ServerUpdateChecker = () => {
|
export const ServerUpdateChecker = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [lastUpdateCheck, setLastUpdateCheck] = useLocalStorage('lastAutomatedServerUpdateCheck', Date.now());
|
const [lastUpdateCheck, setLastUpdateCheck] = useLocalStorage('lastAutomatedServerUpdateCheck', 0);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: serverUpdateCheckData,
|
data: serverUpdateCheckData,
|
||||||
@@ -48,7 +48,8 @@ export const ServerUpdateChecker = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const remainingTimeTillNextUpdateCheck = Date.now() - lastUpdateCheck;
|
const remainingTimeTillNextUpdateCheck =
|
||||||
|
(UPDATE_CHECK_INTERVAL - (Date.now() - lastUpdateCheck)) % UPDATE_CHECK_INTERVAL;
|
||||||
|
|
||||||
let timeout: NodeJS.Timeout | undefined;
|
let timeout: NodeJS.Timeout | undefined;
|
||||||
const scheduleUpdateCheck = (timeoutMS: number) => {
|
const scheduleUpdateCheck = (timeoutMS: number) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user