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,
tab,
silent,
timestamp: new Date().toISOString()
timestamp: new Date().toISOString(),
caller: new Error().stack?.split('\n')[2]?.trim()
});
try {
@@ -556,13 +557,32 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
}
}), [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
useEffect(() => {
if (user) {
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false); // Show loading
if (!user) return;
if (!hasInitialFetchRef.current) {
hasInitialFetchRef.current = true;
fetchItems(debouncedEntityFilter, debouncedStatusFilter, false);
} else {
debouncedFetchItems(debouncedEntityFilter, debouncedStatusFilter, true, activeTab);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedEntityFilter, debouncedStatusFilter, user]);
}, [debouncedEntityFilter, debouncedStatusFilter, user, activeTab]);
// Polling for auto-refresh (only if realtime is disabled)
useEffect(() => {

View File

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