mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 11:11:12 -05:00
Fix fetchItems calls and edge function error
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user