mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 17:11:13 -05:00
Fix moderation queue refreshing
This commit is contained in:
@@ -115,6 +115,15 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
const refreshStrategy = getAutoRefreshStrategy();
|
||||
const preserveInteraction = getPreserveInteractionState();
|
||||
|
||||
// Store admin settings in refs to avoid triggering fetchItems recreation
|
||||
const refreshStrategyRef = useRef(refreshStrategy);
|
||||
const preserveInteractionRef = useRef(preserveInteraction);
|
||||
|
||||
useEffect(() => {
|
||||
refreshStrategyRef.current = refreshStrategy;
|
||||
preserveInteractionRef.current = preserveInteraction;
|
||||
}, [refreshStrategy, preserveInteraction]);
|
||||
|
||||
// Sync itemsRef and loadedIdsRef with items state
|
||||
useEffect(() => {
|
||||
itemsRef.current = items;
|
||||
@@ -461,12 +470,12 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
setIsRefreshing(false);
|
||||
setIsInitialLoad(false);
|
||||
}
|
||||
}, [
|
||||
user,
|
||||
refreshStrategy,
|
||||
preserveInteraction,
|
||||
toast
|
||||
]);
|
||||
}, [user, toast, isAdmin, isSuperuser]);
|
||||
|
||||
// Log when fetchItems is recreated to help debug refresh issues
|
||||
useEffect(() => {
|
||||
console.log('🔄 fetchItems callback recreated');
|
||||
}, [fetchItems]);
|
||||
|
||||
// Debounced filters to prevent rapid-fire calls
|
||||
const debouncedEntityFilter = useDebounce(activeEntityFilter, 500);
|
||||
@@ -490,8 +499,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
if (user) {
|
||||
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false); // Show loading
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [debouncedEntityFilter, debouncedStatusFilter, user]);
|
||||
}, [debouncedEntityFilter, debouncedStatusFilter, user, fetchItems]);
|
||||
|
||||
// Polling for auto-refresh
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user