mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 14:11:18 -05:00
feat: Implement full Phase 3 API optimizations
This commit is contained in:
@@ -110,5 +110,81 @@ export function useQueryInvalidation() {
|
||||
invalidateRides: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['rides'] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate park detail cache
|
||||
* Call this after updating a park
|
||||
*/
|
||||
invalidateParkDetail: (slug: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.parks.detail(slug) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate ride detail cache
|
||||
* Call this after updating a ride
|
||||
*/
|
||||
invalidateRideDetail: (parkSlug: string, rideSlug: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.rides.detail(parkSlug, rideSlug) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate entity reviews
|
||||
* Call this after adding/updating/deleting reviews
|
||||
*/
|
||||
invalidateEntityReviews: (entityType: 'park' | 'ride', entityId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.reviews.entity(entityType, entityId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate user reviews
|
||||
* Call this after a user adds/updates/deletes their reviews
|
||||
*/
|
||||
invalidateUserReviews: (userId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['reviews', 'user', userId] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate entity photos
|
||||
* Call this after uploading/deleting photos
|
||||
*/
|
||||
invalidateEntityPhotos: (entityType: string, entityId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.photos.entity(entityType, entityId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate photo count
|
||||
* Call this after photo changes
|
||||
*/
|
||||
invalidatePhotoCount: (entityType: string, entityId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.photos.count(entityType, entityId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate search results
|
||||
* Call this after major data changes
|
||||
*/
|
||||
invalidateSearchResults: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['search'] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate similar rides
|
||||
* Call this after ride updates
|
||||
*/
|
||||
invalidateSimilarRides: (parkId: string, category: string) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['rides', 'similar', parkId, category]
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate featured parks
|
||||
* Call this after park updates that affect featured status
|
||||
*/
|
||||
invalidateFeaturedParks: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['homepage', 'featured-parks']
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user