mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 05:51:12 -05:00
Fix admin page flashing
This commit is contained in:
@@ -102,18 +102,33 @@ export const useModerationStats = (options: UseModerationStatsOptions = {}) => {
|
||||
|
||||
statsDebounceRef.current = setTimeout(() => {
|
||||
fetchStats(true); // Silent refresh
|
||||
}, 500); // 500ms debounce
|
||||
}, 2000); // 2 second debounce to reduce flashing
|
||||
}, [fetchStats]);
|
||||
|
||||
// Realtime subscription for instant stat updates
|
||||
// Realtime subscription - only trigger on INSERT of new pending items
|
||||
useEffect(() => {
|
||||
if (!enabled || !realtimeEnabled) return;
|
||||
|
||||
const channel = supabase
|
||||
.channel('moderation-stats-realtime')
|
||||
.on('postgres_changes', { event: '*', schema: 'public', table: 'content_submissions' }, debouncedFetchStats)
|
||||
.on('postgres_changes', { event: '*', schema: 'public', table: 'reports' }, debouncedFetchStats)
|
||||
.on('postgres_changes', { event: '*', schema: 'public', table: 'reviews' }, debouncedFetchStats)
|
||||
.on('postgres_changes', {
|
||||
event: 'INSERT',
|
||||
schema: 'public',
|
||||
table: 'content_submissions',
|
||||
filter: 'status=eq.pending'
|
||||
}, debouncedFetchStats)
|
||||
.on('postgres_changes', {
|
||||
event: 'INSERT',
|
||||
schema: 'public',
|
||||
table: 'reports',
|
||||
filter: 'status=eq.pending'
|
||||
}, debouncedFetchStats)
|
||||
.on('postgres_changes', {
|
||||
event: '*',
|
||||
schema: 'public',
|
||||
table: 'reviews',
|
||||
filter: 'moderation_status=eq.flagged'
|
||||
}, debouncedFetchStats)
|
||||
.subscribe();
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user