mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 18:31:12 -05:00
Fix flashing and bouncing
This commit is contained in:
@@ -607,48 +607,6 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [user, refreshMode, pollInterval, isInitialLoad, useRealtimeQueue]);
|
}, [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)
|
// Real-time subscription for NEW submissions (replaces polling)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!user || !useRealtimeQueue) return;
|
if (!user || !useRealtimeQueue) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user