mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 06:51:12 -05:00
Fix moderation queue data loading
This commit is contained in:
@@ -229,7 +229,18 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchItems = useCallback(async (entityFilter: EntityFilter = 'all', statusFilter: StatusFilter = 'pending', silent = false, tab: QueueTab = 'mainQueue') => {
|
const fetchItems = useCallback(async (entityFilter: EntityFilter = 'all', statusFilter: StatusFilter = 'pending', silent = false, tab: QueueTab = 'mainQueue') => {
|
||||||
|
console.log('🔍 fetchItems called:', {
|
||||||
|
hasUser: !!userRef.current,
|
||||||
|
entityFilter,
|
||||||
|
statusFilter,
|
||||||
|
silent,
|
||||||
|
tab,
|
||||||
|
loadingState,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
if (!userRef.current) {
|
if (!userRef.current) {
|
||||||
|
console.warn('⚠️ fetchItems: No user available yet, cannot fetch');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,15 +773,28 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
|
|
||||||
// Initial fetch on mount and filter changes
|
// Initial fetch on mount and filter changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!user) return;
|
console.log('🎯 Initial fetch effect:', {
|
||||||
|
hasUser: !!user,
|
||||||
|
loadingState,
|
||||||
|
hasInitialFetchRef: hasInitialFetchRef.current,
|
||||||
|
initialFetchComplete: initialFetchCompleteRef.current,
|
||||||
|
isMounting: isMountingRef.current
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
console.log('⏳ Waiting for user to be available...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Phase 1: Initial fetch (run once)
|
// Phase 1: Initial fetch (run once)
|
||||||
if (!hasInitialFetchRef.current) {
|
if (!hasInitialFetchRef.current) {
|
||||||
|
console.log('✅ Triggering initial fetch');
|
||||||
hasInitialFetchRef.current = true;
|
hasInitialFetchRef.current = true;
|
||||||
isMountingRef.current = true;
|
isMountingRef.current = true;
|
||||||
|
|
||||||
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false)
|
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
console.log('✅ Initial fetch complete');
|
||||||
initialFetchCompleteRef.current = true;
|
initialFetchCompleteRef.current = true;
|
||||||
// Wait for DOM to paint before allowing subsequent fetches
|
// Wait for DOM to paint before allowing subsequent fetches
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
@@ -782,6 +806,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
|
|
||||||
// Phase 2: Filter changes (only after initial fetch completes)
|
// Phase 2: Filter changes (only after initial fetch completes)
|
||||||
if (!isMountingRef.current && initialFetchCompleteRef.current) {
|
if (!isMountingRef.current && initialFetchCompleteRef.current) {
|
||||||
|
console.log('🔄 Filter changed, fetching with debounce');
|
||||||
debouncedFetchItems(debouncedEntityFilter, debouncedStatusFilter, true, activeTab);
|
debouncedFetchItems(debouncedEntityFilter, debouncedStatusFilter, true, activeTab);
|
||||||
}
|
}
|
||||||
}, [debouncedEntityFilter, debouncedStatusFilter, user, activeTab, fetchItems, debouncedFetchItems]);
|
}, [debouncedEntityFilter, debouncedStatusFilter, user, activeTab, fetchItems, debouncedFetchItems]);
|
||||||
|
|||||||
Reference in New Issue
Block a user