diff --git a/src/components/moderation/ModerationQueue.tsx b/src/components/moderation/ModerationQueue.tsx index ac3ebde1..04cc947a 100644 --- a/src/components/moderation/ModerationQueue.tsx +++ b/src/components/moderation/ModerationQueue.tsx @@ -950,7 +950,7 @@ export const ModerationQueue = forwardRef((props, ref) => { const newTimeout = setTimeout(() => { updateFn(); realtimeUpdateDebounceRef.current.delete(submissionId); - }, 500); // Wait 500ms after last event + }, 1000); // Wait 1000ms after last event realtimeUpdateDebounceRef.current.set(submissionId, newTimeout); }, []); @@ -1076,26 +1076,23 @@ export const ModerationQueue = forwardRef((props, ref) => { const hasChanged = currentItem.status !== fullItem.status || currentItem.reviewed_at !== fullItem.reviewed_at || - currentItem.reviewed_by !== fullItem.reviewed_by || currentItem.reviewer_notes !== fullItem.reviewer_notes || currentItem.assigned_to !== fullItem.assigned_to || currentItem.locked_until !== fullItem.locked_until || + currentItem.escalated !== fullItem.escalated || JSON.stringify(currentItem.content) !== JSON.stringify(fullItem.content); if (!hasChanged) { console.log('✅ Realtime UPDATE: No changes detected for', fullItem.id); - return prev; // Keep existing array reference + return prev; // Keep existing array reference - PREVENTS RE-RENDER } console.log('🔄 Realtime UPDATE: Changes detected for', fullItem.id); - const newItems = prev.map(i => i.id === fullItem.id ? fullItem : i); - itemsRef.current = newItems; // Update ref immediately - return newItems; + // Shallow merge to preserve stable references + return prev.map(i => i.id === fullItem.id ? { ...i, ...fullItem } : i); } else { console.log('🆕 Realtime UPDATE: Adding new item', fullItem.id); - const newItems = [fullItem, ...prev]; - itemsRef.current = newItems; // Update ref immediately - return newItems; + return [fullItem, ...prev]; } }); } catch (error) { diff --git a/src/components/moderation/QueueItem.tsx b/src/components/moderation/QueueItem.tsx index 9745a234..fed84a54 100644 --- a/src/components/moderation/QueueItem.tsx +++ b/src/components/moderation/QueueItem.tsx @@ -670,7 +670,6 @@ export const QueueItem = memo(({ // Deep comparison of content and other fields that affect rendering if (prevProps.item.reviewed_at !== nextProps.item.reviewed_at) return false; - if (prevProps.item.reviewed_by !== nextProps.item.reviewed_by) return false; if (prevProps.item.reviewer_notes !== nextProps.item.reviewer_notes) return false; if (prevProps.item.assigned_to !== nextProps.item.assigned_to) return false; if (prevProps.item.locked_until !== nextProps.item.locked_until) return false;