diff --git a/packages/web/components/templates/library/LibraryContainer.tsx b/packages/web/components/templates/library/LibraryContainer.tsx index f344e609f..2a1d72441 100644 --- a/packages/web/components/templates/library/LibraryContainer.tsx +++ b/packages/web/components/templates/library/LibraryContainer.tsx @@ -188,16 +188,16 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element { .map((li) => li.node.id) }, [libraryItems]) - // const refreshProcessingItems = useRefreshProcessingItems() + const refreshProcessingItems = useRefreshProcessingItems() - // useEffect(() => { - // if (processingItems.length) { - // refreshProcessingItems.mutateAsync({ - // attempt: 0, - // itemIds: processingItems, - // }) - // } - // }, [processingItems]) + useEffect(() => { + if (processingItems.length) { + refreshProcessingItems.mutateAsync({ + attempt: 0, + itemIds: processingItems, + }) + } + }, [processingItems]) const focusFirstItem = useCallback(() => { if (libraryItems.length < 1) { diff --git a/packages/web/lib/networking/library_items/useLibraryItems.tsx b/packages/web/lib/networking/library_items/useLibraryItems.tsx index d9fa8ccbc..73899f857 100644 --- a/packages/web/lib/networking/library_items/useLibraryItems.tsx +++ b/packages/web/lib/networking/library_items/useLibraryItems.tsx @@ -676,6 +676,20 @@ export function useRefreshProcessingItems() { .map((it) => it.node.id) : variables.itemIds, }) + } else if (shouldRefetch) { + console.log('failed for edges: ', data?.edges) + // There are still processing items, but we've reached max attempts + // so we will mark them as failed. + for (const item of data?.edges ?? []) { + if (item.node.state == State.PROCESSING) { + updateItemStateInCache( + queryClient, + item.node.id, + item.node.slug, + State.FAILED + ) + } + } } }, })