mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
fix genre and provider changing
This commit is contained in:
parent
d4969c0540
commit
396fddb496
1 changed files with 17 additions and 3 deletions
|
|
@ -487,7 +487,10 @@ export function useDiscoverMedia({
|
|||
|
||||
try {
|
||||
const data = await attemptFetch(contentType);
|
||||
setMedia((prevMedia) => [...prevMedia, ...data.results]);
|
||||
setMedia((prevMedia) => {
|
||||
// If page is 1, replace the media array, otherwise append
|
||||
return page === 1 ? data.results : [...prevMedia, ...data.results];
|
||||
});
|
||||
setHasMore(data.hasMore);
|
||||
} catch (err) {
|
||||
console.error("Error fetching media:", err);
|
||||
|
|
@ -498,7 +501,12 @@ export function useDiscoverMedia({
|
|||
console.info(`Falling back from ${contentType} to ${fallbackType}`);
|
||||
try {
|
||||
const fallbackData = await attemptFetch(fallbackType);
|
||||
setMedia((prevMedia) => [...prevMedia, ...fallbackData.results]);
|
||||
setMedia((prevMedia) => {
|
||||
// If page is 1, replace the media array, otherwise append
|
||||
return page === 1
|
||||
? fallbackData.results
|
||||
: [...prevMedia, ...fallbackData.results];
|
||||
});
|
||||
setHasMore(fallbackData.hasMore);
|
||||
setError(null); // Clear error if fallback succeeds
|
||||
} catch (fallbackErr) {
|
||||
|
|
@ -521,11 +529,17 @@ export function useDiscoverMedia({
|
|||
fetchTraktMedia,
|
||||
fetchEditorPicks,
|
||||
t,
|
||||
page,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
// Reset media when content type, media type, or id changes
|
||||
if (contentType !== currentContentType || page === 1) {
|
||||
setMedia([]);
|
||||
setCurrentContentType(contentType);
|
||||
}
|
||||
fetchMedia();
|
||||
}, [fetchMedia]);
|
||||
}, [fetchMedia, contentType, currentContentType, page, id]);
|
||||
|
||||
return {
|
||||
media,
|
||||
|
|
|
|||
Loading…
Reference in a new issue