Feature/global update show last update time (#468)
* Show last global update timestamp * Add update button to "Updates" screen
This commit is contained in:
@@ -32,6 +32,9 @@ const calcProgress = (status: UpdaterSubscription['updateStatusChanged'] | undef
|
|||||||
export function UpdateChecker({ handleFinishedUpdate }: { handleFinishedUpdate: () => void }) {
|
export function UpdateChecker({ handleFinishedUpdate }: { handleFinishedUpdate: () => void }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { data: lastUpdateTimestampData, refetch: refetchlastTimestamp } =
|
||||||
|
requestManager.useGetLastGlobalUpdateTimestamp();
|
||||||
|
const lastUpdateTimestamp = lastUpdateTimestampData?.lastUpdateTimestamp.timestamp;
|
||||||
const { data: updaterData } = requestManager.useUpdaterSubscription();
|
const { data: updaterData } = requestManager.useUpdaterSubscription();
|
||||||
const status = updaterData?.updateStatusChanged;
|
const status = updaterData?.updateStatusChanged;
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ export function UpdateChecker({ handleFinishedUpdate }: { handleFinishedUpdate:
|
|||||||
|
|
||||||
const isUpdateFinished = progress === 100;
|
const isUpdateFinished = progress === 100;
|
||||||
if (isUpdateFinished) {
|
if (isUpdateFinished) {
|
||||||
|
refetchlastTimestamp();
|
||||||
handleFinishedUpdate();
|
handleFinishedUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +64,11 @@ export function UpdateChecker({ handleFinishedUpdate }: { handleFinishedUpdate:
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title={t('library.settings.global_update.title')}>
|
<Tooltip
|
||||||
|
title={t('library.settings.global_update.label.last_update_tooltip', {
|
||||||
|
date: lastUpdateTimestamp ? new Date(+lastUpdateTimestamp).toLocaleString() : '-',
|
||||||
|
})}
|
||||||
|
>
|
||||||
<IconButton onClick={onClick} disabled={loading}>
|
<IconButton onClick={onClick} disabled={loading}>
|
||||||
{loading ? <Progress progress={progress} /> : <RefreshIcon />}
|
{loading ? <Progress progress={progress} /> : <RefreshIcon />}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
@@ -382,6 +382,10 @@
|
|||||||
},
|
},
|
||||||
"title": "Skip updating entries"
|
"title": "Skip updating entries"
|
||||||
},
|
},
|
||||||
|
"label": {
|
||||||
|
"last_update": "Last update: {{date}}",
|
||||||
|
"last_update_tooltip": "$t(library.settings.global_update.title) ($t(library.settings.global_update.label.last_update, lowercase))"
|
||||||
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"label": {
|
"label": {
|
||||||
"description": "Check for new cover and details when updating library",
|
"description": "Check for new cover and details when updating library",
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ import {
|
|||||||
GetExtensionsQueryVariables,
|
GetExtensionsQueryVariables,
|
||||||
GetGlobalMetadatasQuery,
|
GetGlobalMetadatasQuery,
|
||||||
GetGlobalMetadatasQueryVariables,
|
GetGlobalMetadatasQueryVariables,
|
||||||
|
GetLastUpdateTimestampQuery,
|
||||||
|
GetLastUpdateTimestampQueryVariables,
|
||||||
GetMangaChaptersFetchMutation,
|
GetMangaChaptersFetchMutation,
|
||||||
GetMangaChaptersFetchMutationVariables,
|
GetMangaChaptersFetchMutationVariables,
|
||||||
GetMangaFetchMutation,
|
GetMangaFetchMutation,
|
||||||
@@ -200,7 +202,7 @@ import {
|
|||||||
UPDATE_CATEGORY_MANGAS,
|
UPDATE_CATEGORY_MANGAS,
|
||||||
UPDATE_LIBRARY_MANGAS,
|
UPDATE_LIBRARY_MANGAS,
|
||||||
} from '@/lib/graphql/mutations/UpdaterMutation.ts';
|
} from '@/lib/graphql/mutations/UpdaterMutation.ts';
|
||||||
import { GET_UPDATE_STATUS } from '@/lib/graphql/queries/UpdaterQuery.ts';
|
import { GET_LAST_UPDATE_TIMESTAMP, GET_UPDATE_STATUS } from '@/lib/graphql/queries/UpdaterQuery.ts';
|
||||||
import { CustomCache } from '@/lib/requests/CustomCache.ts';
|
import { CustomCache } from '@/lib/requests/CustomCache.ts';
|
||||||
import { RESTORE_BACKUP } from '@/lib/graphql/mutations/BackupMutation.ts';
|
import { RESTORE_BACKUP } from '@/lib/graphql/mutations/BackupMutation.ts';
|
||||||
import { GET_RESTORE_STATUS, VALIDATE_BACKUP } from '@/lib/graphql/queries/BackupQuery.ts';
|
import { GET_RESTORE_STATUS, VALIDATE_BACKUP } from '@/lib/graphql/queries/BackupQuery.ts';
|
||||||
@@ -1918,6 +1920,20 @@ export class RequestManager {
|
|||||||
): AbortableApolloUseMutationResponse<DownloadAheadMutation, DownloadAheadMutationVariables> {
|
): AbortableApolloUseMutationResponse<DownloadAheadMutation, DownloadAheadMutationVariables> {
|
||||||
return this.doRequest(GQLMethod.USE_MUTATION, DOWNLOAD_AHEAD, undefined, options);
|
return this.doRequest(GQLMethod.USE_MUTATION, DOWNLOAD_AHEAD, undefined, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public useGetLastGlobalUpdateTimestamp(
|
||||||
|
options?: QueryHookOptions<GetLastUpdateTimestampQuery, GetLastUpdateTimestampQueryVariables>,
|
||||||
|
): AbortableApolloUseQueryResponse<GetLastUpdateTimestampQuery, GetLastUpdateTimestampQueryVariables> {
|
||||||
|
return this.doRequest(
|
||||||
|
GQLMethod.USE_QUERY,
|
||||||
|
GET_LAST_UPDATE_TIMESTAMP,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
...options,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const requestManager = new RequestManager();
|
export const requestManager = new RequestManager();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { DownloadStateIndicator } from '@/components/molecules/DownloadStateIndi
|
|||||||
import { DownloadType } from '@/lib/graphql/generated/graphql.ts';
|
import { DownloadType } from '@/lib/graphql/generated/graphql.ts';
|
||||||
import { TChapter } from '@/typings.ts';
|
import { TChapter } from '@/typings.ts';
|
||||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||||
|
import { UpdateChecker } from '@/components/library/UpdateChecker.tsx';
|
||||||
|
|
||||||
const StyledGroupedVirtuoso = styled(GroupedVirtuoso)(({ theme }) => ({
|
const StyledGroupedVirtuoso = styled(GroupedVirtuoso)(({ theme }) => ({
|
||||||
// 64px header
|
// 64px header
|
||||||
@@ -117,11 +118,24 @@ export const Updates: React.FC = () => {
|
|||||||
const { data: downloaderData } = requestManager.useDownloadSubscription();
|
const { data: downloaderData } = requestManager.useDownloadSubscription();
|
||||||
const queue = (downloaderData?.downloadChanged.queue as DownloadType[]) ?? [];
|
const queue = (downloaderData?.downloadChanged.queue as DownloadType[]) ?? [];
|
||||||
|
|
||||||
|
const { data: lastUpdateTimestampData, refetch: refetchlastTimestamp } =
|
||||||
|
requestManager.useGetLastGlobalUpdateTimestamp();
|
||||||
|
const lastUpdateTimestamp = lastUpdateTimestampData?.lastUpdateTimestamp.timestamp;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle(t('updates.title'));
|
setTitle(t('updates.title'));
|
||||||
|
|
||||||
setAction(null);
|
setAction(
|
||||||
}, [t]);
|
<>
|
||||||
|
<Typography sx={{ marginRight: '10px' }}>
|
||||||
|
{t('library.settings.global_update.label.last_update', {
|
||||||
|
date: lastUpdateTimestamp ? new Date(+lastUpdateTimestamp).toLocaleString() : '-',
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
<UpdateChecker handleFinishedUpdate={() => refetchlastTimestamp()} />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
}, [t, lastUpdateTimestamp]);
|
||||||
|
|
||||||
const downloadForChapter = (chapter: TChapter) => {
|
const downloadForChapter = (chapter: TChapter) => {
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in New Issue
Block a user