Fix/chapter not getting deleted after being read (#532)

* Create permanent subscriptions

The subscriptions have to be permanently open, otherwise, the cache gets outdated.

E.g. in case a view is open, which does not subscribe to the download updates, finished downloads are never received and thus, data of existing chapters/mangas in the cache get outdated

* [Codegen][Tool] Get latest data from cache for automatic chapter deletion after reading

The manga chapters query is on "standby" to prevent the reader from rerender in case the underlying query data updates, which would cause the reader to jump back to the beginning of the last read page.
Thus, when checking if the chapter should be automatically deleted, the data from the query can't be used, since it is outdated.
This commit is contained in:
schroda
2024-01-01 22:40:39 +01:00
committed by GitHub
parent 7d3d82556a
commit 05fa3d0732
12 changed files with 93 additions and 32 deletions

View File

@@ -170,10 +170,17 @@ import {
UpdateMangasCategoriesMutation,
UpdateMangasCategoriesMutationVariables,
UpdateMangaCategoriesPatchInput,
GetWebuiUpdateStatusQuery,
GetWebuiUpdateStatusQueryVariables,
} from '@/lib/graphql/generated/graphql.ts';
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
import { CHECK_FOR_SERVER_UPDATES, CHECK_FOR_WEBUI_UPDATE, GET_ABOUT } from '@/lib/graphql/queries/ServerInfoQuery.ts';
import {
CHECK_FOR_SERVER_UPDATES,
CHECK_FOR_WEBUI_UPDATE,
GET_ABOUT,
GET_WEBUI_UPDATE_STATUS,
} from '@/lib/graphql/queries/ServerInfoQuery.ts';
import { GET_EXTENSIONS } from '@/lib/graphql/queries/ExtensionQuery.ts';
import {
GET_EXTENSIONS_FETCH,
@@ -2104,8 +2111,8 @@ export class RequestManager {
}
public useGetDownloadStatus(
options?: SubscriptionHookOptions<GetDownloadStatusQuery, GetDownloadStatusQueryVariables>,
): SubscriptionResult<GetDownloadStatusQuery, GetDownloadStatusQueryVariables> {
options?: QueryHookOptions<GetDownloadStatusQuery, GetDownloadStatusQueryVariables>,
): AbortableApolloUseQueryResponse<GetDownloadStatusQuery, GetDownloadStatusQueryVariables> {
return this.doRequest(GQLMethod.USE_QUERY, GET_DOWNLOAD_STATUS, {}, options);
}
@@ -2163,6 +2170,12 @@ export class RequestManager {
): AbortableApolloMutationResponse<ResetWebuiUpdateStatusMutation> {
return this.doRequest(GQLMethod.MUTATION, RESET_WEBUI_UPDATE_STATUS, undefined, options);
}
public useGetWebUIUpdateStatus(
options?: QueryHookOptions<GetWebuiUpdateStatusQuery, GetWebuiUpdateStatusQueryVariables>,
): AbortableApolloUseQueryResponse<GetWebuiUpdateStatusQuery, GetWebuiUpdateStatusQueryVariables> {
return this.doRequest(GQLMethod.USE_QUERY, GET_WEBUI_UPDATE_STATUS, undefined, options);
}
}
export const requestManager = new RequestManager();

View File

@@ -26,6 +26,8 @@ const typePolicies: StrictTypedTypePolicies = {
SettingsType: { keyFields: [] },
DownloadStatus: { keyFields: [] },
DownloadType: { keyFields: ['chapter'] },
WebUIUpdateStatus: { keyFields: [] },
UpdateStatus: { keyFields: [] },
Query: {
fields: {
manga(_, { args, toReference }) {
@@ -58,6 +60,21 @@ const typePolicies: StrictTypedTypePolicies = {
key: args?.key,
});
},
downloadStatus(_, { toReference }) {
return toReference({
__typename: 'DownloadStatus',
key: {},
});
},
getWebUIUpdateStatus(_, { toReference }) {
return toReference({
__typename: 'WebUIUpdateStatus',
key: {},
});
},
updateStatus(_, { toReference }) {
return toReference({ __typename: 'UpdateStatus', key: {} });
},
chapters: {
keyArgs: ['condition', 'filter', 'orderBy', 'orderByType'],
merge(existing, incoming) {