Add option to clear the server cache (#487)
This commit is contained in:
@@ -402,7 +402,7 @@ export type MultiSelectListPreferenceFieldPolicy = {
|
||||
title?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
visible?: FieldPolicy<any> | FieldReadFunction<any>
|
||||
};
|
||||
export type MutationKeySpecifier = ('clearCachedImages' | 'clearDownloader' | 'createBackup' | 'createCategory' | 'deleteCategory' | 'deleteCategoryMeta' | 'deleteChapterMeta' | 'deleteDownloadedChapter' | 'deleteDownloadedChapters' | 'deleteGlobalMeta' | 'deleteMangaMeta' | 'dequeueChapterDownload' | 'dequeueChapterDownloads' | 'downloadAhead' | 'enqueueChapterDownload' | 'enqueueChapterDownloads' | 'fetchChapterPages' | 'fetchChapters' | 'fetchExtensions' | 'fetchManga' | 'fetchSourceManga' | 'installExternalExtension' | 'reorderChapterDownload' | 'resetSettings' | 'restoreBackup' | 'setCategoryMeta' | 'setChapterMeta' | 'setGlobalMeta' | 'setMangaMeta' | 'setSettings' | 'startDownloader' | 'stopDownloader' | 'updateCategories' | 'updateCategory' | 'updateCategoryManga' | 'updateCategoryOrder' | 'updateChapter' | 'updateChapters' | 'updateExtension' | 'updateExtensions' | 'updateLibraryManga' | 'updateManga' | 'updateMangaCategories' | 'updateMangas' | 'updateMangasCategories' | 'updateSourcePreference' | 'updateStop' | 'updateWebUI' | MutationKeySpecifier)[];
|
||||
export type MutationKeySpecifier = ('clearCachedImages' | 'clearDownloader' | 'createBackup' | 'createCategory' | 'deleteCategory' | 'deleteCategoryMeta' | 'deleteChapterMeta' | 'deleteDownloadedChapter' | 'deleteDownloadedChapters' | 'deleteGlobalMeta' | 'deleteMangaMeta' | 'dequeueChapterDownload' | 'dequeueChapterDownloads' | 'downloadAhead' | 'enqueueChapterDownload' | 'enqueueChapterDownloads' | 'fetchChapterPages' | 'fetchChapters' | 'fetchExtensions' | 'fetchManga' | 'fetchSourceManga' | 'installExternalExtension' | 'reorderChapterDownload' | 'resetSettings' | 'resetWebUIUpdateStatus' | 'restoreBackup' | 'setCategoryMeta' | 'setChapterMeta' | 'setGlobalMeta' | 'setMangaMeta' | 'setSettings' | 'startDownloader' | 'stopDownloader' | 'updateCategories' | 'updateCategory' | 'updateCategoryManga' | 'updateCategoryOrder' | 'updateChapter' | 'updateChapters' | 'updateExtension' | 'updateExtensions' | 'updateLibraryManga' | 'updateManga' | 'updateMangaCategories' | 'updateMangas' | 'updateMangasCategories' | 'updateSourcePreference' | 'updateStop' | 'updateWebUI' | MutationKeySpecifier)[];
|
||||
export type MutationFieldPolicy = {
|
||||
clearCachedImages?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
clearDownloader?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
@@ -428,6 +428,7 @@ export type MutationFieldPolicy = {
|
||||
installExternalExtension?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
reorderChapterDownload?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
resetSettings?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
resetWebUIUpdateStatus?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
restoreBackup?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
setCategoryMeta?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
setChapterMeta?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
@@ -833,11 +834,10 @@ export type WebUIUpdateCheckFieldPolicy = {
|
||||
tag?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
updateAvailable?: FieldPolicy<any> | FieldReadFunction<any>
|
||||
};
|
||||
export type WebUIUpdateInfoKeySpecifier = ('channel' | 'tag' | 'updateAvailable' | WebUIUpdateInfoKeySpecifier)[];
|
||||
export type WebUIUpdateInfoKeySpecifier = ('channel' | 'tag' | WebUIUpdateInfoKeySpecifier)[];
|
||||
export type WebUIUpdateInfoFieldPolicy = {
|
||||
channel?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
tag?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
updateAvailable?: FieldPolicy<any> | FieldReadFunction<any>
|
||||
tag?: FieldPolicy<any> | FieldReadFunction<any>
|
||||
};
|
||||
export type WebUIUpdatePayloadKeySpecifier = ('clientMutationId' | 'updateStatus' | WebUIUpdatePayloadKeySpecifier)[];
|
||||
export type WebUIUpdatePayloadFieldPolicy = {
|
||||
|
||||
@@ -952,6 +952,7 @@ export type Mutation = {
|
||||
installExternalExtension: InstallExternalExtensionPayload;
|
||||
reorderChapterDownload: ReorderChapterDownloadPayload;
|
||||
resetSettings: ResetSettingsPayload;
|
||||
resetWebUIUpdateStatus: WebUiUpdateStatus;
|
||||
restoreBackup: RestoreBackupPayload;
|
||||
setCategoryMeta: SetCategoryMetaPayload;
|
||||
setChapterMeta: SetChapterMetaPayload;
|
||||
@@ -2017,7 +2018,7 @@ export enum UpdateState {
|
||||
Downloading = 'DOWNLOADING',
|
||||
Error = 'ERROR',
|
||||
Finished = 'FINISHED',
|
||||
Stopped = 'STOPPED'
|
||||
Idle = 'IDLE'
|
||||
}
|
||||
|
||||
export type UpdateStatus = {
|
||||
@@ -2093,7 +2094,6 @@ export type WebUiUpdateInfo = {
|
||||
__typename?: 'WebUIUpdateInfo';
|
||||
channel: Scalars['String']['output'];
|
||||
tag: Scalars['String']['output'];
|
||||
updateAvailable: Scalars['Boolean']['output'];
|
||||
};
|
||||
|
||||
export type WebUiUpdateInput = {
|
||||
@@ -2395,6 +2395,13 @@ export type SetGlobalMetadataMutationVariables = Exact<{
|
||||
|
||||
export type SetGlobalMetadataMutation = { __typename?: 'Mutation', setGlobalMeta: { __typename?: 'SetGlobalMetaPayload', clientMutationId?: string | null, meta: { __typename?: 'GlobalMetaType', key: string, value: string } } };
|
||||
|
||||
export type ClearServerCacheMutationVariables = Exact<{
|
||||
input: ClearCachedImagesInput;
|
||||
}>;
|
||||
|
||||
|
||||
export type ClearServerCacheMutation = { __typename?: 'Mutation', clearCachedImages: { __typename?: 'ClearCachedImagesPayload', clientMutationId?: string | null, cachedPages?: boolean | null, cachedThumbnails?: boolean | null, downloadedThumbnails?: boolean | null } };
|
||||
|
||||
export type DeleteMangaMetadataMutationVariables = Exact<{
|
||||
input: DeleteMangaMetaInput;
|
||||
}>;
|
||||
|
||||
20
src/lib/graphql/mutations/ImageMutation.ts
Normal file
20
src/lib/graphql/mutations/ImageMutation.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const CLEAR_SERVER_CACHE = gql`
|
||||
mutation CLEAR_SERVER_CACHE($input: ClearCachedImagesInput!) {
|
||||
clearCachedImages(input: $input) {
|
||||
clientMutationId
|
||||
cachedPages
|
||||
cachedThumbnails
|
||||
downloadedThumbnails
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -35,8 +35,11 @@ import {
|
||||
ChapterOrderBy,
|
||||
CheckForServerUpdatesQuery,
|
||||
CheckForServerUpdatesQueryVariables,
|
||||
ClearCachedImagesInput,
|
||||
ClearDownloaderMutation,
|
||||
ClearDownloaderMutationVariables,
|
||||
ClearServerCacheMutation,
|
||||
ClearServerCacheMutationVariables,
|
||||
CreateCategoryInput,
|
||||
CreateCategoryMutation,
|
||||
CreateCategoryMutationVariables,
|
||||
@@ -212,6 +215,7 @@ import { UPDATER_SUBSCRIPTION } from '@/lib/graphql/subscriptions/UpdaterSubscri
|
||||
import { GET_SERVER_SETTINGS } from '@/lib/graphql/queries/SettingsQuery.ts';
|
||||
import { UPDATE_SERVER_SETTINGS } from '@/lib/graphql/mutations/SettingsMutation.ts';
|
||||
import { BASE_MANGA_FIELDS, FULL_EXTENSION_FIELDS } from '@/lib/graphql/Fragments.ts';
|
||||
import { CLEAR_SERVER_CACHE } from '@/lib/graphql/mutations/ImageMutation.ts';
|
||||
|
||||
enum GQLMethod {
|
||||
QUERY = 'QUERY',
|
||||
@@ -1993,6 +1997,13 @@ export class RequestManager {
|
||||
): AbortableApolloUseQueryResponse<GetLastUpdateTimestampQuery, GetLastUpdateTimestampQueryVariables> {
|
||||
return this.doRequest(GQLMethod.USE_QUERY, GET_LAST_UPDATE_TIMESTAMP, {}, options);
|
||||
}
|
||||
|
||||
public useClearServerCache(
|
||||
input: ClearCachedImagesInput = { cachedPages: true, cachedThumbnails: true, downloadedThumbnails: true },
|
||||
options?: MutationHookOptions<ClearServerCacheMutation, ClearServerCacheMutationVariables>,
|
||||
): AbortableApolloUseMutationResponse<ClearServerCacheMutation, ClearServerCacheMutationVariables> {
|
||||
return this.doRequest(GQLMethod.USE_MUTATION, CLEAR_SERVER_CACHE, { input }, options);
|
||||
}
|
||||
}
|
||||
|
||||
export const requestManager = new RequestManager();
|
||||
|
||||
Reference in New Issue
Block a user