Fix flashing and bouncing

This commit is contained in:
gpt-engineer-app[bot]
2025-10-09 17:17:20 +00:00
parent 356cf2b54b
commit 9d3bdcf2e0

View File

@@ -607,48 +607,6 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user, refreshMode, pollInterval, isInitialLoad, useRealtimeQueue]);
// Real-time subscription for lock status (optimized to prevent unnecessary updates)
useEffect(() => {
if (!user) return;
const channel = supabase
.channel('moderation-locks')
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'content_submissions',
},
(payload) => {
const newData = payload.new as any;
const isLocked = newData.assigned_to && newData.assigned_to !== user.id &&
newData.locked_until && new Date(newData.locked_until) > new Date();
const wasLocked = prevLocksRef.current.get(newData.id) || false;
// Only update if lock state actually changed
if (isLocked !== wasLocked) {
prevLocksRef.current.set(newData.id, isLocked);
setLockedSubmissions((prev) => {
const next = new Set(prev);
if (isLocked) {
next.add(newData.id);
} else {
next.delete(newData.id);
}
return next;
});
}
}
)
.subscribe();
return () => {
supabase.removeChannel(channel);
};
}, [user]);
// Real-time subscription for NEW submissions (replaces polling)
useEffect(() => {
if (!user || !useRealtimeQueue) return;