Fix force page reload decision after a webui update

This commit is contained in:
schroda
2025-12-06 17:00:49 +01:00
parent 84cfa6bea5
commit e914c04c88
5 changed files with 8 additions and 11 deletions

View File

@@ -14,7 +14,6 @@ import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogActions from '@mui/material/DialogActions';
import Button from '@mui/material/Button';
import { d } from 'koration';
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import { UpdateState, WebUiChannel, WebUiUpdateStatus } from '@/lib/graphql/generated/graphql.ts';
import { useLocalStorage, useSessionStorage } from '@/base/hooks/useStorage.tsx';
@@ -30,8 +29,6 @@ import { BrowserUtil } from '@/lib/BrowserUtil.ts';
const disabledUpdateCheck = () => Promise.resolve();
const FORCED_REFRESH_THRESHOLD = d(30).seconds.inWholeMilliseconds;
const INITIAL_LOAD_TIMESTAMP_KEY = 'webUIInitialLoadTimestamp';
if (BrowserUtil.isActualPageLoad()) {
@@ -82,9 +79,7 @@ export const WebUIUpdateChecker = () => {
const newVersion = aboutWebUI?.tag;
const isSameAsCurrent = !newVersion || !webUIVersion || webUIVersion === newVersion;
// Calculate if forced refresh threshold has been met
const timeSinceLoad = Date.now() - (initialLoadTimestamp ?? Date.now());
const shouldForceRefresh = timeSinceLoad >= FORCED_REFRESH_THRESHOLD;
const shouldForceRefresh = initialLoadTimestamp < Number(aboutWebUI?.updateTimestamp);
const saveInitialVersion = !webUIVersion && !!newVersion;
if (saveInitialVersion) {

View File

@@ -12,6 +12,7 @@ export const ABOUT_WEBUI = gql`
fragment ABOUT_WEBUI on AboutWebUI {
channel
tag
updateTimestamp
}
`;

View File

@@ -14,10 +14,11 @@ export type AboutServerPayloadFieldPolicy = {
revision?: FieldPolicy<any> | FieldReadFunction<any>,
version?: FieldPolicy<any> | FieldReadFunction<any>
};
export type AboutWebUIKeySpecifier = ('channel' | 'tag' | AboutWebUIKeySpecifier)[];
export type AboutWebUIKeySpecifier = ('channel' | 'tag' | 'updateTimestamp' | AboutWebUIKeySpecifier)[];
export type AboutWebUIFieldPolicy = {
channel?: FieldPolicy<any> | FieldReadFunction<any>,
tag?: FieldPolicy<any> | FieldReadFunction<any>
tag?: FieldPolicy<any> | FieldReadFunction<any>,
updateTimestamp?: FieldPolicy<any> | FieldReadFunction<any>
};
export type BackupRestoreStatusKeySpecifier = ('mangaProgress' | 'state' | 'totalManga' | BackupRestoreStatusKeySpecifier)[];
export type BackupRestoreStatusFieldPolicy = {

View File

@@ -34,6 +34,7 @@ export type AboutWebUi = {
__typename?: 'AboutWebUI';
channel: WebUiChannel;
tag: Scalars['String']['output'];
updateTimestamp: Scalars['LongString']['output'];
};
export enum AuthMode {
@@ -3263,7 +3264,7 @@ export type PageInfoFragment = { __typename?: 'PageInfo', endCursor?: string | n
export type GlobalMetadataFragment = { __typename?: 'GlobalMetaType', key: string, value: string };
export type AboutWebuiFragment = { __typename?: 'AboutWebUI', channel: WebUiChannel, tag: string };
export type AboutWebuiFragment = { __typename?: 'AboutWebUI', channel: WebUiChannel, tag: string, updateTimestamp: string };
export type WebuiUpdateCheckFragment = { __typename?: 'WebUIUpdateCheck', channel: WebUiChannel, tag: string, updateAvailable: boolean };
@@ -4057,7 +4058,7 @@ export type GetLibraryMangaCountQuery = { __typename?: 'Query', mangas: { __type
export type GetAboutQueryVariables = Exact<{ [key: string]: never; }>;
export type GetAboutQuery = { __typename?: 'Query', aboutServer: { __typename?: 'AboutServerPayload', buildTime: string, buildType: string, discord: string, github: string, name: string, revision: string, version: string }, aboutWebUI: { __typename?: 'AboutWebUI', channel: WebUiChannel, tag: string } };
export type GetAboutQuery = { __typename?: 'Query', aboutServer: { __typename?: 'AboutServerPayload', buildTime: string, buildType: string, discord: string, github: string, name: string, version: string }, aboutWebUI: { __typename?: 'AboutWebUI', channel: WebUiChannel, tag: string, updateTimestamp: string } };
export type CheckForServerUpdatesQueryVariables = Exact<{ [key: string]: never; }>;

View File

@@ -18,7 +18,6 @@ export const GET_ABOUT = gql`
discord
github
name
revision
version
}
aboutWebUI {