mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
Fix view more pages
more content, now shows correct media when trakt fails and also scrolls to the top
This commit is contained in:
parent
6a3d81a048
commit
1025ea087d
4 changed files with 14 additions and 3 deletions
|
|
@ -97,6 +97,11 @@ export function MoreContent({ onShowDetails }: MoreContentProps) {
|
|||
setIsContentVisible(false);
|
||||
}, [isLoading, mediaItems, currentPage]);
|
||||
|
||||
// Scroll to top when entering the page
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [contentType, mediaType, id]);
|
||||
|
||||
const handleBack = () => {
|
||||
if (lastView) {
|
||||
navigate(lastView.url);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ export function MediaCarousel({
|
|||
]);
|
||||
|
||||
// Fetch media using our hook - only when carousel has been visible
|
||||
const { media, sectionTitle } = useDiscoverMedia({
|
||||
const { media, sectionTitle, actualContentType } = useDiscoverMedia({
|
||||
contentType,
|
||||
mediaType,
|
||||
id: selectedProviderId || selectedGenreId || selectedRecommendationId,
|
||||
|
|
@ -298,7 +298,7 @@ export function MediaCarousel({
|
|||
if (showRecommendations && selectedRecommendationId) {
|
||||
return `${baseLink}/recommendations/${selectedRecommendationId}/${mediaType}`;
|
||||
}
|
||||
return `${baseLink}/${content.type}/${mediaType}`;
|
||||
return `${baseLink}/${actualContentType}/${mediaType}`;
|
||||
}, [
|
||||
moreLink,
|
||||
showProviders,
|
||||
|
|
@ -308,7 +308,7 @@ export function MediaCarousel({
|
|||
showRecommendations,
|
||||
selectedRecommendationId,
|
||||
mediaType,
|
||||
content.type,
|
||||
actualContentType,
|
||||
]);
|
||||
|
||||
// Loading state
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ export function useDiscoverMedia({
|
|||
const [sectionTitle, setSectionTitle] = useState<string>("");
|
||||
const [currentContentType, setCurrentContentType] =
|
||||
useState<string>(contentType);
|
||||
const [actualContentType, setActualContentType] =
|
||||
useState<DiscoverContentType>(contentType);
|
||||
|
||||
const { t } = useTranslation();
|
||||
const userLanguage = useLanguageStore((s) => s.language);
|
||||
|
|
@ -131,6 +133,7 @@ export function useDiscoverMedia({
|
|||
if (contentType !== currentContentType) {
|
||||
setMedia([]);
|
||||
setCurrentContentType(contentType);
|
||||
setActualContentType(contentType); // Reset actual content type to original
|
||||
}
|
||||
}, [contentType, currentContentType]);
|
||||
|
||||
|
|
@ -475,6 +478,7 @@ export function useDiscoverMedia({
|
|||
console.info(`Falling back from ${contentType} to ${fallbackType}`);
|
||||
try {
|
||||
const fallbackData = await attemptFetch(fallbackType);
|
||||
setActualContentType(fallbackType); // Set actual content type to fallback
|
||||
setMedia((prevMedia) => {
|
||||
// If page is 1, replace the media array, otherwise append
|
||||
return page === 1
|
||||
|
|
@ -526,5 +530,6 @@ export function useDiscoverMedia({
|
|||
hasMore,
|
||||
refetch: fetchMedia,
|
||||
sectionTitle,
|
||||
actualContentType,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export interface UseDiscoverMediaReturn {
|
|||
hasMore: boolean;
|
||||
refetch: () => Promise<void>;
|
||||
sectionTitle: string;
|
||||
actualContentType: DiscoverContentType;
|
||||
}
|
||||
|
||||
export interface Provider {
|
||||
|
|
|
|||
Loading…
Reference in a new issue