Fix fetchItems calls and edge function error

This commit is contained in:
gpt-engineer-app[bot]
2025-10-09 15:53:01 +00:00
parent 039fe46e55
commit cf31f94c44
2 changed files with 25 additions and 6 deletions

View File

@@ -165,7 +165,8 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
statusFilter, statusFilter,
tab, tab,
silent, silent,
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
caller: new Error().stack?.split('\n')[2]?.trim()
}); });
try { try {
@@ -556,13 +557,32 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
} }
}), [fetchItems]); }), [fetchItems]);
// Track if initial fetch has happened
const hasInitialFetchRef = useRef(false);
// Debounced version of fetchItems for filter changes
const fetchDebounceRef = useRef<NodeJS.Timeout | null>(null);
const debouncedFetchItems = useCallback((entityFilter: EntityFilter, statusFilter: StatusFilter, silent: boolean, tab: QueueTab = 'mainQueue') => {
if (fetchDebounceRef.current) {
clearTimeout(fetchDebounceRef.current);
}
fetchDebounceRef.current = setTimeout(() => {
fetchItems(entityFilter, statusFilter, silent, tab);
}, 100);
}, [fetchItems]);
// Initial fetch on mount and filter changes // Initial fetch on mount and filter changes
useEffect(() => { useEffect(() => {
if (user) { if (!user) return;
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false); // Show loading
if (!hasInitialFetchRef.current) {
hasInitialFetchRef.current = true;
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false);
} else {
debouncedFetchItems(debouncedEntityFilter, debouncedStatusFilter, true, activeTab);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedEntityFilter, debouncedStatusFilter, user]); }, [debouncedEntityFilter, debouncedStatusFilter, user, activeTab]);
// Polling for auto-refresh (only if realtime is disabled) // Polling for auto-refresh (only if realtime is disabled)
useEffect(() => { useEffect(() => {

View File

@@ -154,8 +154,7 @@ Deno.serve(async (req) => {
submission_type: type, submission_type: type,
status: 'pending', status: 'pending',
content: contentData, content: contentData,
submitted_at: new Date().toISOString(), submitted_at: new Date().toISOString()
priority: options.escalated ? 10 : randomInt(1, 5)
}; };
if (options.escalated) { if (options.escalated) {