mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 16:11:13 -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,
|
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(() => {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user