mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 17:31:13 -05:00
Fix sorting mechanism
This commit is contained in:
@@ -163,6 +163,12 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
*/
|
||||
const fetchItems = useCallback(
|
||||
async (silent = false) => {
|
||||
console.log('🔄 [fetchItems RECREATED]', {
|
||||
sortField: sort.field,
|
||||
sortDirection: sort.direction,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
|
||||
if (!user) return;
|
||||
|
||||
// Get caller info
|
||||
@@ -259,6 +265,12 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
submissionsQuery = submissionsQuery.order('created_at', { ascending: true });
|
||||
}
|
||||
|
||||
// Validate sort was applied
|
||||
if (!sortColumn) {
|
||||
console.error('❌ [Query] Sort column is undefined! Using fallback.');
|
||||
submissionsQuery = submissionsQuery.order('created_at', { ascending: true });
|
||||
}
|
||||
|
||||
// Apply tab-based status filtering
|
||||
const tab = filters.activeTab;
|
||||
const statusFilter = filters.debouncedStatusFilter;
|
||||
@@ -501,7 +513,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
setLoadingState("ready");
|
||||
}
|
||||
},
|
||||
[user, isAdmin, isSuperuser, filters, pagination, profileCache, entityCache, toast, sort],
|
||||
[user, isAdmin, isSuperuser, filters, pagination, profileCache, entityCache, toast, sort.field, sort.direction],
|
||||
);
|
||||
|
||||
// Store fetchItems in ref to avoid re-creating visibility listener
|
||||
@@ -949,7 +961,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
console.log('✅ Triggering refetch due to sort change');
|
||||
fetchItemsRef.current(false);
|
||||
}
|
||||
}, [sort.config.field, sort.config.direction]);
|
||||
}, [sort.field, sort.direction]);
|
||||
|
||||
// Initialize realtime subscriptions
|
||||
useRealtimeSubscriptions({
|
||||
|
||||
Reference in New Issue
Block a user