From e914c04c88dbfd14e2d30650f44fb70fc46e8899 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 6 Dec 2025 17:00:49 +0100 Subject: [PATCH] Fix force page reload decision after a webui update --- src/features/app-updates/components/WebUIUpdateChecker.tsx | 7 +------ src/lib/graphql/fragments/InfoFragments.ts | 1 + src/lib/graphql/generated/apollo-helpers.ts | 5 +++-- src/lib/graphql/generated/graphql.ts | 5 +++-- src/lib/graphql/queries/ServerInfoQuery.ts | 1 - 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/features/app-updates/components/WebUIUpdateChecker.tsx b/src/features/app-updates/components/WebUIUpdateChecker.tsx index 6887d8d3..3d6e95e1 100644 --- a/src/features/app-updates/components/WebUIUpdateChecker.tsx +++ b/src/features/app-updates/components/WebUIUpdateChecker.tsx @@ -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) { diff --git a/src/lib/graphql/fragments/InfoFragments.ts b/src/lib/graphql/fragments/InfoFragments.ts index f4b75784..0de3ec49 100644 --- a/src/lib/graphql/fragments/InfoFragments.ts +++ b/src/lib/graphql/fragments/InfoFragments.ts @@ -12,6 +12,7 @@ export const ABOUT_WEBUI = gql` fragment ABOUT_WEBUI on AboutWebUI { channel tag + updateTimestamp } `; diff --git a/src/lib/graphql/generated/apollo-helpers.ts b/src/lib/graphql/generated/apollo-helpers.ts index b4a4ac3e..69685b0c 100644 --- a/src/lib/graphql/generated/apollo-helpers.ts +++ b/src/lib/graphql/generated/apollo-helpers.ts @@ -14,10 +14,11 @@ export type AboutServerPayloadFieldPolicy = { revision?: FieldPolicy | FieldReadFunction, version?: FieldPolicy | FieldReadFunction }; -export type AboutWebUIKeySpecifier = ('channel' | 'tag' | AboutWebUIKeySpecifier)[]; +export type AboutWebUIKeySpecifier = ('channel' | 'tag' | 'updateTimestamp' | AboutWebUIKeySpecifier)[]; export type AboutWebUIFieldPolicy = { channel?: FieldPolicy | FieldReadFunction, - tag?: FieldPolicy | FieldReadFunction + tag?: FieldPolicy | FieldReadFunction, + updateTimestamp?: FieldPolicy | FieldReadFunction }; export type BackupRestoreStatusKeySpecifier = ('mangaProgress' | 'state' | 'totalManga' | BackupRestoreStatusKeySpecifier)[]; export type BackupRestoreStatusFieldPolicy = { diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index 001f6078..09ac400c 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -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; }>; diff --git a/src/lib/graphql/queries/ServerInfoQuery.ts b/src/lib/graphql/queries/ServerInfoQuery.ts index 6756fe36..fa090510 100644 --- a/src/lib/graphql/queries/ServerInfoQuery.ts +++ b/src/lib/graphql/queries/ServerInfoQuery.ts @@ -18,7 +18,6 @@ export const GET_ABOUT = gql` discord github name - revision version } aboutWebUI {