mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
Fixed sub/click count disapparing after editing a recommendation (#18279)
closes https://github.com/TryGhost/Product/issues/3929
This commit is contained in:
parent
b578cd5fa0
commit
b10767d038
@ -51,7 +51,7 @@ export const useBrowseRecommendations = createInfiniteQuery<RecommendationRespon
|
||||
export const useDeleteRecommendation = createMutation<RecommendationDeleteResponseType, Recommendation>({
|
||||
method: 'DELETE',
|
||||
path: recommendation => `/recommendations/${recommendation.id}/`,
|
||||
// Clear all queries because pagination needs to be re-checked
|
||||
|
||||
invalidateQueries: {
|
||||
dataType
|
||||
}
|
||||
@ -61,15 +61,9 @@ export const useEditRecommendation = createMutation<RecommendationEditResponseTy
|
||||
method: 'PUT',
|
||||
path: recommendation => `/recommendations/${recommendation.id}/`,
|
||||
body: recommendation => ({recommendations: [recommendation]}),
|
||||
updateQueries: {
|
||||
dataType,
|
||||
update: (newData, currentData) => (currentData && {
|
||||
...(currentData as RecommendationResponseType),
|
||||
recommendations: (currentData as RecommendationResponseType).recommendations.map((recommendation) => {
|
||||
const newRecommendation = newData.recommendations.find(({id}) => id === recommendation.id);
|
||||
return newRecommendation || recommendation;
|
||||
})
|
||||
})
|
||||
|
||||
invalidateQueries: {
|
||||
dataType
|
||||
}
|
||||
});
|
||||
|
||||
@ -78,7 +72,6 @@ export const useAddRecommendation = createMutation<RecommendationResponseType, P
|
||||
path: () => '/recommendations/',
|
||||
body: ({...recommendation}) => ({recommendations: [recommendation]}),
|
||||
|
||||
// Clear all queries because pagination needs to be re-checked
|
||||
invalidateQueries: {
|
||||
dataType
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user