From ecf1d901a346b1915d384cc2bb02f262f90a0c03 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 21:35:09 +0100 Subject: [PATCH] Fix issue with current source displaying in scraping screen --- src/hooks/useProviderScrape.tsx | 2 ++ src/pages/parts/player/ScrapingPart.tsx | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hooks/useProviderScrape.tsx b/src/hooks/useProviderScrape.tsx index 44f823da..7e1ab4bf 100644 --- a/src/hooks/useProviderScrape.tsx +++ b/src/hooks/useProviderScrape.tsx @@ -60,8 +60,10 @@ function useBaseScrape() { }, []); const startEvent = useCallback((id: ScraperEvent<"start">) => { + const lastIdTmp = lastId.current; setSources((s) => { if (s[id]) s[id].status = "pending"; + if (lastIdTmp && s[lastIdTmp]) s[lastIdTmp].status = "success"; return { ...s }; }); setCurrentSource(id); diff --git a/src/pages/parts/player/ScrapingPart.tsx b/src/pages/parts/player/ScrapingPart.tsx index ea86ee57..6687d3b1 100644 --- a/src/pages/parts/player/ScrapingPart.tsx +++ b/src/pages/parts/player/ScrapingPart.tsx @@ -75,11 +75,8 @@ export function ScrapingPart(props: ScrapingProps) { })(); }, [startScraping, props, report, isMounted]); - const currentProvider = sourceOrder.find( - (s) => sources[s.id].status === "pending", - ); let currentProviderIndex = sourceOrder.findIndex( - (provider) => currentProvider?.id === provider.id, + (s) => s.id === currentSource || s.children.includes(currentSource ?? ""), ); if (currentProviderIndex === -1) currentProviderIndex = sourceOrder.length - 1;