diff --git a/src/components/moderation/ModerationQueue.tsx b/src/components/moderation/ModerationQueue.tsx index 17626351..c761540c 100644 --- a/src/components/moderation/ModerationQueue.tsx +++ b/src/components/moderation/ModerationQueue.tsx @@ -503,6 +503,7 @@ export const ModerationQueue = forwardRef((props, ref) => { if (mergeResult.hasChanges) { setItems(mergeResult.items); + itemsRef.current = mergeResult.items; // Update ref immediately to prevent stale comparisons console.log('🔄 Queue updated (replace mode):', { added: mergeResult.changes.added.length, removed: mergeResult.changes.removed.length, @@ -534,6 +535,7 @@ export const ModerationQueue = forwardRef((props, ref) => { if (mergeResult.hasChanges) { setItems(mergeResult.items); + itemsRef.current = mergeResult.items; // Update ref immediately to prevent stale comparisons console.log('🔄 Queue updated (manual refresh):', { added: mergeResult.changes.added.length, removed: mergeResult.changes.removed.length, @@ -932,10 +934,14 @@ export const ModerationQueue = forwardRef((props, ref) => { } console.log('🔄 Realtime UPDATE: Changes detected for', fullItem.id); - return prev.map(i => i.id === fullItem.id ? fullItem : i); + const newItems = prev.map(i => i.id === fullItem.id ? fullItem : i); + itemsRef.current = newItems; // Update ref immediately + return newItems; } else { console.log('🆕 Realtime UPDATE: Adding new item', fullItem.id); - return [fullItem, ...prev]; + const newItems = [fullItem, ...prev]; + itemsRef.current = newItems; // Update ref immediately + return newItems; } }); } catch (error) {