diff --git a/ui/v2.5/src/App.tsx b/ui/v2.5/src/App.tsx index eed4da776..d670786af 100644 --- a/ui/v2.5/src/App.tsx +++ b/ui/v2.5/src/App.tsx @@ -277,7 +277,7 @@ export const App: React.FC = () => { status === GQL.SystemStatusEnum.NeedsMigration ) { // redirect to migrate page - history.push("/migrate"); + history.replace("/migrate"); } }, [systemStatusData, setupMatch, history, location]); diff --git a/ui/v2.5/src/components/Setup/Migrate.tsx b/ui/v2.5/src/components/Setup/Migrate.tsx index 2f8e38f55..9060e4878 100644 --- a/ui/v2.5/src/components/Setup/Migrate.tsx +++ b/ui/v2.5/src/components/Setup/Migrate.tsx @@ -7,12 +7,13 @@ import { useSystemStatus, mutateMigrate, postMigrate, + refetchSystemStatus, } from "src/core/StashService"; import { migrationNotes } from "src/docs/en/MigrationNotes"; import { ExternalLink } from "../Shared/ExternalLink"; import { LoadingIndicator } from "../Shared/LoadingIndicator"; import { MarkdownPage } from "../Shared/MarkdownPage"; -import { useMonitorJob } from "src/utils/job"; +import { JobFragment, useMonitorJob } from "src/utils/job"; export const Migrate: React.FC = () => { const intl = useIntl(); @@ -26,7 +27,7 @@ export const Migrate: React.FC = () => { const [jobID, setJobID] = useState(); - const { job } = useMonitorJob(jobID, (finishedJob) => { + function onJobFinished(finishedJob?: JobFragment) { setJobID(undefined); setMigrateLoading(false); @@ -34,9 +35,12 @@ export const Migrate: React.FC = () => { setMigrateError(finishedJob.error); } else { postMigrate(); - history.push("/"); + // refetch the system status so that the we get redirected + refetchSystemStatus(); } - }); + } + + const { job } = useMonitorJob(jobID, onJobFinished); // if database path includes path separators, then this is passed through // to the migration path. Extract the base name of the database file. @@ -147,7 +151,7 @@ export const Migrate: React.FC = () => { systemStatus.systemStatus.status !== GQL.SystemStatusEnum.NeedsMigration ) { // redirect to main page - history.push("/"); + history.replace("/"); return ; } diff --git a/ui/v2.5/src/core/StashService.ts b/ui/v2.5/src/core/StashService.ts index d6432fc95..6ccc52db8 100644 --- a/ui/v2.5/src/core/StashService.ts +++ b/ui/v2.5/src/core/StashService.ts @@ -2229,6 +2229,11 @@ export const queryLogs = () => }); export const useSystemStatus = () => GQL.useSystemStatusQuery(); +export const refetchSystemStatus = () => { + client.refetchQueries({ + include: [GQL.SystemStatusDocument], + }); +}; export const useJobsSubscribe = () => GQL.useJobsSubscribeSubscription();