Feature/global update last timestamp use stale data while fetching (#473)

* Cache last update timestamp

* Correctly detect update as finished

The update status on server side does not get reset, thus, in case a previous update was finished, it would get detected as finished and handled once on the initial render.
This commit is contained in:
schroda
2023-11-25 15:35:36 +01:00
committed by GitHub
parent a4bd44de9e
commit 7c69a4a5a1
3 changed files with 27 additions and 20 deletions

View File

@@ -118,8 +118,12 @@ export const Updates: React.FC = () => {
const { data: downloaderData } = requestManager.useDownloadSubscription();
const queue = (downloaderData?.downloadChanged.queue as DownloadType[]) ?? [];
const { data: lastUpdateTimestampData, refetch: refetchlastTimestamp } =
requestManager.useGetLastGlobalUpdateTimestamp();
const { data: lastUpdateTimestampData } = requestManager.useGetLastGlobalUpdateTimestamp({
/**
* The {@link UpdateChecker} is responsible for updating the timestamp
*/
fetchPolicy: 'cache-only',
});
const lastUpdateTimestamp = lastUpdateTimestampData?.lastUpdateTimestamp.timestamp;
useEffect(() => {
@@ -132,7 +136,7 @@ export const Updates: React.FC = () => {
date: lastUpdateTimestamp ? new Date(+lastUpdateTimestamp).toLocaleString() : '-',
})}
</Typography>
<UpdateChecker handleFinishedUpdate={() => refetchlastTimestamp()} />
<UpdateChecker />
</>,
);
}, [t, lastUpdateTimestamp]);