fix random errors

This commit is contained in:
Pas 2025-12-06 21:17:19 -07:00
parent 8b115ebb43
commit b927c6971e
6 changed files with 56 additions and 10 deletions

View file

@ -38,7 +38,7 @@
<meta name="msapplication-TileColor" content="#120f1d" />
<meta name="theme-color" content="#000000" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"

View file

@ -7,15 +7,26 @@ export function paginateResults(
pageSize: number = 20,
contentType: "movie" | "tv" | "both" = "both",
): PaginatedTraktResponse {
if (!results) {
return {
tmdb_ids: [],
hasMore: false,
totalCount: 0,
};
}
let tmdbIds: number[];
if (contentType === "movie") {
tmdbIds = results.movie_tmdb_ids;
tmdbIds = results.movie_tmdb_ids || [];
} else if (contentType === "tv") {
tmdbIds = results.tv_tmdb_ids;
tmdbIds = results.tv_tmdb_ids || [];
} else {
// For 'both', combine movies and TV shows
tmdbIds = [...results.movie_tmdb_ids, ...results.tv_tmdb_ids];
tmdbIds = [
...(results.movie_tmdb_ids || []),
...(results.tv_tmdb_ids || []),
];
}
const startIndex = (page - 1) * pageSize;

View file

@ -155,8 +155,21 @@ function MigrationRunner() {
function TheRouter(props: { children: ReactNode }) {
const normalRouter = conf().NORMAL_ROUTER;
if (normalRouter) return <BrowserRouter>{props.children}</BrowserRouter>;
return <HashRouter>{props.children}</HashRouter>;
if (normalRouter)
return (
<BrowserRouter
future={{ v7_startTransition: true, v7_relativeSplatPath: true }}
>
{props.children}
</BrowserRouter>
);
return (
<HashRouter
future={{ v7_startTransition: true, v7_relativeSplatPath: true }}
>
{props.children}
</HashRouter>
);
}
// Checks if the extension is installed

View file

@ -184,6 +184,11 @@ export function useDiscoverMedia({
// Race between the Trakt request and timeout
const response = await Promise.race([traktFunction(), timeoutPromise]);
// Check if response is null
if (!response) {
throw new Error("Trakt API returned null response");
}
// Paginate the results
const pageSize = isCarouselView ? 20 : 100; // Limit to 20 items for carousels, get more for detailed views
const { tmdb_ids: tmdbIds, hasMore: hasMoreResults } = paginateResults(
@ -317,6 +322,15 @@ export function useDiscoverMedia({
}, [mediaType, formattedLanguage, isCarouselView]);
const fetchMedia = useCallback(async () => {
// Skip fetching recommendations if no ID is provided
if (contentType === "recommendations" && !id) {
setIsLoading(false);
setMedia([]);
setHasMore(false);
setSectionTitle("");
return;
}
setIsLoading(true);
setError(null);

View file

@ -94,6 +94,7 @@ export function HeroPart({
paddingTop: `${topOffset}px`,
}}
onFixedToggle={stickStateChanged}
scrollElement="window"
>
<SearchBarInput
ref={inputRef}

View file

@ -32,12 +32,19 @@ export function initializeChromecast() {
const context = (
window as any
).cast.framework.CastContext.getInstance();
context.setOptions({
const options: any = {
receiverApplicationId: (window as any).chrome?.cast?.media
?.DEFAULT_MEDIA_RECEIVER_APP_ID,
autoJoinPolicy: (window as any).cast.framework.AutoJoinPolicy
.ORIGIN_SCOPED,
});
};
// Only set autoJoinPolicy if AutoJoinPolicy exists
if ((window as any).cast.framework.AutoJoinPolicy?.ORIGIN_SCOPED) {
options.autoJoinPolicy = (
window as any
).cast.framework.AutoJoinPolicy.ORIGIN_SCOPED;
}
context.setOptions(options);
}
} catch (e) {
console.warn("Chromecast initialization error:", e);