mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 14:11:13 -05:00
Fix: Resolve stale cache issues in moderation flow
This commit is contained in:
@@ -4,6 +4,7 @@ import { useToast } from "@/hooks/use-toast";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { getErrorMessage } from "@/lib/errorHandler";
|
||||
import { MODERATION_CONSTANTS } from "@/lib/moderation/constants";
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import type { User } from "@supabase/supabase-js";
|
||||
import {
|
||||
useEntityCache,
|
||||
@@ -81,6 +82,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
});
|
||||
|
||||
const { user, isAdmin, isSuperuser, toast, settings } = config;
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Initialize sub-hooks
|
||||
const filters = useModerationFilters({
|
||||
@@ -379,7 +381,11 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
// Refresh stats to update counts
|
||||
queue.refreshStats();
|
||||
|
||||
// Immediately refetch queue data to show fresh results
|
||||
// Force cache invalidation before refetching to ensure fresh data
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ['moderation-queue'],
|
||||
exact: false // Invalidate all query variants
|
||||
});
|
||||
await queueQuery.refetch();
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
|
||||
Reference in New Issue
Block a user