Fix force page reload decision after a webui update
This commit is contained in:
@@ -14,7 +14,6 @@ import DialogContent from '@mui/material/DialogContent';
|
|||||||
import DialogContentText from '@mui/material/DialogContentText';
|
import DialogContentText from '@mui/material/DialogContentText';
|
||||||
import DialogActions from '@mui/material/DialogActions';
|
import DialogActions from '@mui/material/DialogActions';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import { d } from 'koration';
|
|
||||||
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
||||||
import { UpdateState, WebUiChannel, WebUiUpdateStatus } from '@/lib/graphql/generated/graphql.ts';
|
import { UpdateState, WebUiChannel, WebUiUpdateStatus } from '@/lib/graphql/generated/graphql.ts';
|
||||||
import { useLocalStorage, useSessionStorage } from '@/base/hooks/useStorage.tsx';
|
import { useLocalStorage, useSessionStorage } from '@/base/hooks/useStorage.tsx';
|
||||||
@@ -30,8 +29,6 @@ import { BrowserUtil } from '@/lib/BrowserUtil.ts';
|
|||||||
|
|
||||||
const disabledUpdateCheck = () => Promise.resolve();
|
const disabledUpdateCheck = () => Promise.resolve();
|
||||||
|
|
||||||
const FORCED_REFRESH_THRESHOLD = d(30).seconds.inWholeMilliseconds;
|
|
||||||
|
|
||||||
const INITIAL_LOAD_TIMESTAMP_KEY = 'webUIInitialLoadTimestamp';
|
const INITIAL_LOAD_TIMESTAMP_KEY = 'webUIInitialLoadTimestamp';
|
||||||
|
|
||||||
if (BrowserUtil.isActualPageLoad()) {
|
if (BrowserUtil.isActualPageLoad()) {
|
||||||
@@ -82,9 +79,7 @@ export const WebUIUpdateChecker = () => {
|
|||||||
const newVersion = aboutWebUI?.tag;
|
const newVersion = aboutWebUI?.tag;
|
||||||
const isSameAsCurrent = !newVersion || !webUIVersion || webUIVersion === newVersion;
|
const isSameAsCurrent = !newVersion || !webUIVersion || webUIVersion === newVersion;
|
||||||
|
|
||||||
// Calculate if forced refresh threshold has been met
|
const shouldForceRefresh = initialLoadTimestamp < Number(aboutWebUI?.updateTimestamp);
|
||||||
const timeSinceLoad = Date.now() - (initialLoadTimestamp ?? Date.now());
|
|
||||||
const shouldForceRefresh = timeSinceLoad >= FORCED_REFRESH_THRESHOLD;
|
|
||||||
|
|
||||||
const saveInitialVersion = !webUIVersion && !!newVersion;
|
const saveInitialVersion = !webUIVersion && !!newVersion;
|
||||||
if (saveInitialVersion) {
|
if (saveInitialVersion) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export const ABOUT_WEBUI = gql`
|
|||||||
fragment ABOUT_WEBUI on AboutWebUI {
|
fragment ABOUT_WEBUI on AboutWebUI {
|
||||||
channel
|
channel
|
||||||
tag
|
tag
|
||||||
|
updateTimestamp
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ export type AboutServerPayloadFieldPolicy = {
|
|||||||
revision?: FieldPolicy<any> | FieldReadFunction<any>,
|
revision?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||||
version?: 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 = {
|
export type AboutWebUIFieldPolicy = {
|
||||||
channel?: FieldPolicy<any> | FieldReadFunction<any>,
|
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 BackupRestoreStatusKeySpecifier = ('mangaProgress' | 'state' | 'totalManga' | BackupRestoreStatusKeySpecifier)[];
|
||||||
export type BackupRestoreStatusFieldPolicy = {
|
export type BackupRestoreStatusFieldPolicy = {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export type AboutWebUi = {
|
|||||||
__typename?: 'AboutWebUI';
|
__typename?: 'AboutWebUI';
|
||||||
channel: WebUiChannel;
|
channel: WebUiChannel;
|
||||||
tag: Scalars['String']['output'];
|
tag: Scalars['String']['output'];
|
||||||
|
updateTimestamp: Scalars['LongString']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum AuthMode {
|
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 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 };
|
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 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; }>;
|
export type CheckForServerUpdatesQueryVariables = Exact<{ [key: string]: never; }>;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export const GET_ABOUT = gql`
|
|||||||
discord
|
discord
|
||||||
github
|
github
|
||||||
name
|
name
|
||||||
revision
|
|
||||||
version
|
version
|
||||||
}
|
}
|
||||||
aboutWebUI {
|
aboutWebUI {
|
||||||
|
|||||||
Reference in New Issue
Block a user