Fix forced reload detection when tab is resumed after WebUI update
In case the tab gets resumed, it does not get fully reloaded but does reexecute js. This caused the initial timestamp to get overwritten and lead to the forced reload detection to be incorrect, because it assumed that the app just got loaded.
This commit is contained in:
@@ -33,7 +33,7 @@ const FORCED_REFRESH_THRESHOLD = d(30).seconds.inWholeMilliseconds;
|
||||
|
||||
const INITIAL_LOAD_TIMESTAMP_KEY = 'webUIInitialLoadTimestamp';
|
||||
|
||||
AppStorage.session.setItem(INITIAL_LOAD_TIMESTAMP_KEY, Date.now());
|
||||
AppStorage.session.setItemIfMissing(INITIAL_LOAD_TIMESTAMP_KEY, Date.now());
|
||||
|
||||
export const WebUIUpdateChecker = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -63,6 +63,12 @@ export class Storage {
|
||||
this.storage.setItem(key, valueToStore);
|
||||
fireEvent(valueToStore as string);
|
||||
}
|
||||
|
||||
setItemIfMissing(key: string, value: unknown, emitEvent?: boolean): void {
|
||||
if (this.getItem(key) === null) {
|
||||
this.setItem(key, value, emitEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class AppStorage {
|
||||
|
||||
Reference in New Issue
Block a user