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 refreshStrategy = getAutoRefreshStrategy();
|
||||||
const preserveInteraction = getPreserveInteractionState();
|
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
|
// Sync itemsRef and loadedIdsRef with items state
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
itemsRef.current = items;
|
itemsRef.current = items;
|
||||||
@@ -461,12 +470,12 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
setIsRefreshing(false);
|
setIsRefreshing(false);
|
||||||
setIsInitialLoad(false);
|
setIsInitialLoad(false);
|
||||||
}
|
}
|
||||||
}, [
|
}, [user, toast, isAdmin, isSuperuser]);
|
||||||
user,
|
|
||||||
refreshStrategy,
|
// Log when fetchItems is recreated to help debug refresh issues
|
||||||
preserveInteraction,
|
useEffect(() => {
|
||||||
toast
|
console.log('🔄 fetchItems callback recreated');
|
||||||
]);
|
}, [fetchItems]);
|
||||||
|
|
||||||
// Debounced filters to prevent rapid-fire calls
|
// Debounced filters to prevent rapid-fire calls
|
||||||
const debouncedEntityFilter = useDebounce(activeEntityFilter, 500);
|
const debouncedEntityFilter = useDebounce(activeEntityFilter, 500);
|
||||||
@@ -490,8 +499,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false); // Show loading
|
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false); // Show loading
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [debouncedEntityFilter, debouncedStatusFilter, user, fetchItems]);
|
||||||
}, [debouncedEntityFilter, debouncedStatusFilter, user]);
|
|
||||||
|
|
||||||
// Polling for auto-refresh
|
// Polling for auto-refresh
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user