mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 10:31:13 -05:00
Improve moderation queue filtering and sorting for faster feedback
Refactor count query logic in useModerationQueueManager to apply all filters and reduce sort debounce time in useModerationSort to 0ms. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ef7037e7-a631-48a2-94d1-9a4b52d7c35a Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7cdf4e95-3f41-4180-b8e3-8ef56d032c0e/ef7037e7-a631-48a2-94d1-9a4b52d7c35a/kq6AhNt
This commit is contained in:
@@ -73,6 +73,12 @@ export interface ModerationQueueManager {
|
|||||||
* Consolidates all queue-related logic into a single hook
|
* Consolidates all queue-related logic into a single hook
|
||||||
*/
|
*/
|
||||||
export function useModerationQueueManager(config: ModerationQueueManagerConfig): ModerationQueueManager {
|
export function useModerationQueueManager(config: ModerationQueueManagerConfig): ModerationQueueManager {
|
||||||
|
console.log('🚀 [QUEUE MANAGER] Hook mounting/rendering', {
|
||||||
|
hasUser: !!config.user,
|
||||||
|
isAdmin: config.isAdmin,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
const { user, isAdmin, isSuperuser, toast, settings } = config;
|
const { user, isAdmin, isSuperuser, toast, settings } = config;
|
||||||
|
|
||||||
// Initialize sub-hooks
|
// Initialize sub-hooks
|
||||||
@@ -280,11 +286,42 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get total count
|
// Get total count - build separate query with same filters
|
||||||
const { count } = await supabase
|
let countQuery = supabase
|
||||||
.from("content_submissions")
|
.from("content_submissions")
|
||||||
.select("*", { count: "exact", head: true })
|
.select("*", { count: "exact", head: true });
|
||||||
.match(submissionsQuery as any);
|
|
||||||
|
// Apply same filters as main query
|
||||||
|
if (tab === "mainQueue") {
|
||||||
|
if (statusFilter === "all") {
|
||||||
|
countQuery = countQuery.in("status", ["pending", "flagged", "partially_approved"]);
|
||||||
|
} else if (statusFilter === "pending") {
|
||||||
|
countQuery = countQuery.in("status", ["pending", "partially_approved"]);
|
||||||
|
} else {
|
||||||
|
countQuery = countQuery.eq("status", statusFilter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (statusFilter === "all") {
|
||||||
|
countQuery = countQuery.in("status", ["approved", "rejected"]);
|
||||||
|
} else {
|
||||||
|
countQuery = countQuery.eq("status", statusFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entityFilter === "photos") {
|
||||||
|
countQuery = countQuery.eq("submission_type", "photo");
|
||||||
|
} else if (entityFilter === "submissions") {
|
||||||
|
countQuery = countQuery.neq("submission_type", "photo");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAdmin && !isSuperuser) {
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
countQuery = countQuery.or(
|
||||||
|
`assigned_to.is.null,locked_until.lt.${now},assigned_to.eq.${user.id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { count } = await countQuery;
|
||||||
|
|
||||||
pagination.setTotalCount(count || 0);
|
pagination.setTotalCount(count || 0);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useDebounce } from '@/hooks/useDebounce';
|
|||||||
import type { SortConfig, SortField } from '@/types/moderation';
|
import type { SortConfig, SortField } from '@/types/moderation';
|
||||||
|
|
||||||
const STORAGE_KEY = 'moderationQueue_sortConfig';
|
const STORAGE_KEY = 'moderationQueue_sortConfig';
|
||||||
const SORT_DEBOUNCE_MS = 300;
|
const SORT_DEBOUNCE_MS = 0; // Changed from 300ms to 0ms for immediate feedback
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default sort configuration
|
* Default sort configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user