mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 17:11:13 -05:00
Refactor: Implement API and cache improvements
This commit is contained in:
@@ -95,6 +95,70 @@ export function useQueryInvalidation() {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate user profile cache
|
||||
* Call this after profile updates
|
||||
*/
|
||||
invalidateUserProfile: (userId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.profile.detail(userId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate profile stats cache
|
||||
* Call this after profile-related changes
|
||||
*/
|
||||
invalidateProfileStats: (userId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.profile.stats(userId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate profile activity cache
|
||||
* Call this after activity changes
|
||||
*/
|
||||
invalidateProfileActivity: (userId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['profile', 'activity', userId] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate user search results
|
||||
* Call this when display names change
|
||||
*/
|
||||
invalidateUserSearch: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['users', 'search'] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate admin settings cache
|
||||
* Call this after updating admin settings
|
||||
*/
|
||||
invalidateAdminSettings: () => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.admin.settings() });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate audit logs cache
|
||||
* Call this after inserting audit log entries
|
||||
*/
|
||||
invalidateAuditLogs: (userId?: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.admin.auditLogs(userId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate contact submissions cache
|
||||
* Call this after updating contact submissions
|
||||
*/
|
||||
invalidateContactSubmissions: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-contact-submissions'] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate blog posts cache
|
||||
* Call this after creating/updating/deleting blog posts
|
||||
*/
|
||||
invalidateBlogPosts: () => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.admin.blogPosts() });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate parks listing cache
|
||||
* Call this after creating/updating/deleting parks
|
||||
@@ -211,22 +275,6 @@ export function useQueryInvalidation() {
|
||||
queryClient.invalidateQueries({ queryKey: ['companies', 'parks', id, type] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate profile activity cache
|
||||
* Call this after user activity changes
|
||||
*/
|
||||
invalidateProfileActivity: (userId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['profile', 'activity', userId] });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate profile stats cache
|
||||
* Call this after user stats changes
|
||||
*/
|
||||
invalidateProfileStats: (userId: string) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.profile.stats(userId) });
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate ride model detail cache
|
||||
* Call this after updating a ride model
|
||||
@@ -324,14 +372,5 @@ export function useQueryInvalidation() {
|
||||
queryKey: queryKeys.entities.name(entityType, entityId)
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Invalidate user profile cache
|
||||
*/
|
||||
invalidateUserProfile: (userId: string) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['profiles', userId]
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,6 +88,11 @@ export const queryKeys = {
|
||||
// Admin queries
|
||||
admin: {
|
||||
versionAudit: ['admin', 'version-audit'] as const,
|
||||
settings: () => ['admin-settings'] as const,
|
||||
blogPosts: () => ['admin-blog-posts'] as const,
|
||||
contactSubmissions: (statusFilter?: string, categoryFilter?: string, searchQuery?: string, showArchived?: boolean) =>
|
||||
['admin-contact-submissions', statusFilter, categoryFilter, searchQuery, showArchived] as const,
|
||||
auditLogs: (userId?: string) => ['admin', 'audit-logs', userId] as const,
|
||||
},
|
||||
|
||||
// Moderation queries
|
||||
|
||||
Reference in New Issue
Block a user