fix more content page loading

This commit is contained in:
Pas 2025-06-04 13:16:39 -06:00
parent 7d09f0b0e0
commit 743f5ffabc
4 changed files with 16 additions and 6 deletions

View file

@ -21,7 +21,7 @@ export interface TraktReleaseResponse {
export type TraktContentType = "movie" | "episode";
export const TRAKT_BASE_URL = "https://airdate.up.railway.app";
export const TRAKT_BASE_URL = "https://fed-airdate.pstream.org";
export async function getLatestReleases(): Promise<TraktLatestResponse> {
const response = await fetch(`${TRAKT_BASE_URL}/latest`);

View file

@ -88,7 +88,7 @@ export function MoreContent({ onShowDetails }: MoreContentProps) {
// Handle content visibility
useEffect(() => {
if (!isLoading) {
if (!isLoading || currentPage > 1) {
// Small delay to ensure smooth transition
const timer = setTimeout(() => {
setIsContentVisible(true);
@ -96,7 +96,7 @@ export function MoreContent({ onShowDetails }: MoreContentProps) {
return () => clearTimeout(timer);
}
setIsContentVisible(false);
}, [isLoading, mediaItems]);
}, [isLoading, mediaItems, currentPage]);
const handleBack = () => {
if (lastView) {

View file

@ -503,7 +503,7 @@ export function MediaCarousel({
<div className="md:w-12" />
{media.length > 0
? media.map((item) => (
? media.slice(0, 20).map((item) => (
<div
onContextMenu={(e: React.MouseEvent<HTMLDivElement>) =>
e.preventDefault()

View file

@ -276,11 +276,21 @@ export function useDiscoverMedia({
const [error, setError] = useState<string | null>(null);
const [hasMore, setHasMore] = useState(true);
const [sectionTitle, setSectionTitle] = useState<string>("");
const [currentContentType, setCurrentContentType] =
useState<string>(contentType);
const { t } = useTranslation();
const userLanguage = useLanguageStore.getState().language;
const formattedLanguage = getTmdbLanguageCode(userLanguage);
// Reset media when content type or media type changes
useEffect(() => {
if (contentType !== currentContentType) {
setMedia([]);
setCurrentContentType(contentType);
}
}, [contentType, currentContentType]);
const fetchTMDBMedia = useCallback(
async (endpoint: string, params: Record<string, any> = {}) => {
try {
@ -477,7 +487,7 @@ export function useDiscoverMedia({
try {
const data = await attemptFetch(contentType);
setMedia(data.results);
setMedia((prevMedia) => [...prevMedia, ...data.results]);
setHasMore(data.hasMore);
} catch (err) {
console.error("Error fetching media:", err);
@ -488,7 +498,7 @@ export function useDiscoverMedia({
console.info(`Falling back from ${contentType} to ${fallbackType}`);
try {
const fallbackData = await attemptFetch(fallbackType);
setMedia(fallbackData.results);
setMedia((prevMedia) => [...prevMedia, ...fallbackData.results]);
setHasMore(fallbackData.hasMore);
setError(null); // Clear error if fallback succeeds
} catch (fallbackErr) {