mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 11:35:06 +01:00
Fix incorrect last source status
Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
parent
76d715a751
commit
bb192ee21f
@ -26,6 +26,8 @@ export function useScrape() {
|
|||||||
const startScraping = useCallback(
|
const startScraping = useCallback(
|
||||||
async (media: ScrapeMedia) => {
|
async (media: ScrapeMedia) => {
|
||||||
if (!providers) return null;
|
if (!providers) return null;
|
||||||
|
|
||||||
|
let lastId: string | null = null;
|
||||||
const output = await providers.runAll({
|
const output = await providers.runAll({
|
||||||
media,
|
media,
|
||||||
events: {
|
events: {
|
||||||
@ -56,6 +58,7 @@ export function useScrape() {
|
|||||||
return { ...s };
|
return { ...s };
|
||||||
});
|
});
|
||||||
setCurrentSource(id);
|
setCurrentSource(id);
|
||||||
|
lastId = id;
|
||||||
},
|
},
|
||||||
update(evt) {
|
update(evt) {
|
||||||
setSources((s) => {
|
setSources((s) => {
|
||||||
@ -94,6 +97,14 @@ export function useScrape() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (output && lastId) {
|
||||||
|
setSources((s) => {
|
||||||
|
if (!lastId) return s;
|
||||||
|
if (s[lastId]) s[lastId].status = "success";
|
||||||
|
return { ...s };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
[setSourceOrder, setSources]
|
[setSourceOrder, setSources]
|
||||||
|
Loading…
Reference in New Issue
Block a user