mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 14:11:18 -05:00
Refactor homepage content fetching
This commit is contained in:
@@ -68,5 +68,31 @@ export function useQueryInvalidation() {
|
||||
invalidateModerationStats: () => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.moderationStats() });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate homepage data
|
||||
* Call this after creating/updating parks or rides
|
||||
*/
|
||||
invalidateHomepageData: (entityType?: 'parks' | 'rides' | 'all') => {
|
||||
if (!entityType || entityType === 'all') {
|
||||
queryClient.invalidateQueries({ queryKey: ['homepage'] });
|
||||
} else if (entityType === 'parks') {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['homepage'],
|
||||
predicate: (query) => {
|
||||
const key = query.queryKey[1] as string;
|
||||
return typeof key === 'string' && key.includes('parks');
|
||||
}
|
||||
});
|
||||
} else if (entityType === 'rides') {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['homepage'],
|
||||
predicate: (query) => {
|
||||
const key = query.queryKey[1] as string;
|
||||
return typeof key === 'string' && key.includes('rides');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user