Add optimistic response to server settings mutation
This commit is contained in:
@@ -133,6 +133,7 @@ import {
|
|||||||
SetMangaMetadataMutationVariables,
|
SetMangaMetadataMutationVariables,
|
||||||
SetSourceMetadataMutation,
|
SetSourceMetadataMutation,
|
||||||
SetSourceMetadataMutationVariables,
|
SetSourceMetadataMutationVariables,
|
||||||
|
SettingsType,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
SourcePreferenceChangeInput,
|
SourcePreferenceChangeInput,
|
||||||
StartDownloaderMutation,
|
StartDownloaderMutation,
|
||||||
@@ -2657,7 +2658,24 @@ export class RequestManager {
|
|||||||
public useUpdateServerSettings(
|
public useUpdateServerSettings(
|
||||||
options?: MutationHookOptions<UpdateServerSettingsMutation, UpdateServerSettingsMutationVariables>,
|
options?: MutationHookOptions<UpdateServerSettingsMutation, UpdateServerSettingsMutationVariables>,
|
||||||
): AbortableApolloUseMutationResponse<UpdateServerSettingsMutation, UpdateServerSettingsMutationVariables> {
|
): AbortableApolloUseMutationResponse<UpdateServerSettingsMutation, UpdateServerSettingsMutationVariables> {
|
||||||
return this.doRequest(GQLMethod.USE_MUTATION, UPDATE_SERVER_SETTINGS, undefined, options);
|
const [mutate, result] = this.doRequest(GQLMethod.USE_MUTATION, UPDATE_SERVER_SETTINGS, undefined, options);
|
||||||
|
|
||||||
|
const wrappedMutate = async (mutateOptions: Parameters<typeof mutate>[0]) =>
|
||||||
|
mutate({
|
||||||
|
optimisticResponse: {
|
||||||
|
__typename: 'Mutation',
|
||||||
|
setSettings: {
|
||||||
|
__typename: 'SetSettingsPayload',
|
||||||
|
settings: {
|
||||||
|
__typename: 'SettingsType',
|
||||||
|
...(mutateOptions?.variables?.input.settings ?? {}),
|
||||||
|
} as SettingsType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...mutateOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
return [wrappedMutate, result];
|
||||||
}
|
}
|
||||||
|
|
||||||
public useGetLastGlobalUpdateTimestamp(
|
public useGetLastGlobalUpdateTimestamp(
|
||||||
|
|||||||
@@ -144,6 +144,14 @@ const typePolicies: StrictTypedTypePolicies = {
|
|||||||
return existingWithAppendedIncoming;
|
return existingWithAppendedIncoming;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
settings: {
|
||||||
|
merge(existing, incoming) {
|
||||||
|
return {
|
||||||
|
...(existing ?? {}),
|
||||||
|
...(incoming ?? {}),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user