mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 11:11:12 -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
|
||||
*/
|
||||
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;
|
||||
|
||||
// Initialize sub-hooks
|
||||
@@ -280,11 +286,42 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
);
|
||||
}
|
||||
|
||||
// Get total count
|
||||
const { count } = await supabase
|
||||
// Get total count - build separate query with same filters
|
||||
let countQuery = supabase
|
||||
.from("content_submissions")
|
||||
.select("*", { count: "exact", head: true })
|
||||
.match(submissionsQuery as any);
|
||||
.select("*", { count: "exact", head: true });
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user