mirror of
https://github.com/p-stream/p-stream.git
synced 2026-01-11 20:10:32 +00:00
fix random errors
This commit is contained in:
parent
8b115ebb43
commit
b927c6971e
6 changed files with 56 additions and 10 deletions
|
|
@ -38,7 +38,7 @@
|
||||||
<meta name="msapplication-TileColor" content="#120f1d" />
|
<meta name="msapplication-TileColor" content="#120f1d" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
|
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
<meta
|
<meta
|
||||||
name="apple-mobile-web-app-status-bar-style"
|
name="apple-mobile-web-app-status-bar-style"
|
||||||
content="black-translucent"
|
content="black-translucent"
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,26 @@ export function paginateResults(
|
||||||
pageSize: number = 20,
|
pageSize: number = 20,
|
||||||
contentType: "movie" | "tv" | "both" = "both",
|
contentType: "movie" | "tv" | "both" = "both",
|
||||||
): PaginatedTraktResponse {
|
): PaginatedTraktResponse {
|
||||||
|
if (!results) {
|
||||||
|
return {
|
||||||
|
tmdb_ids: [],
|
||||||
|
hasMore: false,
|
||||||
|
totalCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let tmdbIds: number[];
|
let tmdbIds: number[];
|
||||||
|
|
||||||
if (contentType === "movie") {
|
if (contentType === "movie") {
|
||||||
tmdbIds = results.movie_tmdb_ids;
|
tmdbIds = results.movie_tmdb_ids || [];
|
||||||
} else if (contentType === "tv") {
|
} else if (contentType === "tv") {
|
||||||
tmdbIds = results.tv_tmdb_ids;
|
tmdbIds = results.tv_tmdb_ids || [];
|
||||||
} else {
|
} else {
|
||||||
// For 'both', combine movies and TV shows
|
// 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;
|
const startIndex = (page - 1) * pageSize;
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,21 @@ function MigrationRunner() {
|
||||||
function TheRouter(props: { children: ReactNode }) {
|
function TheRouter(props: { children: ReactNode }) {
|
||||||
const normalRouter = conf().NORMAL_ROUTER;
|
const normalRouter = conf().NORMAL_ROUTER;
|
||||||
|
|
||||||
if (normalRouter) return <BrowserRouter>{props.children}</BrowserRouter>;
|
if (normalRouter)
|
||||||
return <HashRouter>{props.children}</HashRouter>;
|
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
|
// Checks if the extension is installed
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,11 @@ export function useDiscoverMedia({
|
||||||
// Race between the Trakt request and timeout
|
// Race between the Trakt request and timeout
|
||||||
const response = await Promise.race([traktFunction(), timeoutPromise]);
|
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
|
// Paginate the results
|
||||||
const pageSize = isCarouselView ? 20 : 100; // Limit to 20 items for carousels, get more for detailed views
|
const pageSize = isCarouselView ? 20 : 100; // Limit to 20 items for carousels, get more for detailed views
|
||||||
const { tmdb_ids: tmdbIds, hasMore: hasMoreResults } = paginateResults(
|
const { tmdb_ids: tmdbIds, hasMore: hasMoreResults } = paginateResults(
|
||||||
|
|
@ -317,6 +322,15 @@ export function useDiscoverMedia({
|
||||||
}, [mediaType, formattedLanguage, isCarouselView]);
|
}, [mediaType, formattedLanguage, isCarouselView]);
|
||||||
|
|
||||||
const fetchMedia = useCallback(async () => {
|
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);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ export function HeroPart({
|
||||||
paddingTop: `${topOffset}px`,
|
paddingTop: `${topOffset}px`,
|
||||||
}}
|
}}
|
||||||
onFixedToggle={stickStateChanged}
|
onFixedToggle={stickStateChanged}
|
||||||
|
scrollElement="window"
|
||||||
>
|
>
|
||||||
<SearchBarInput
|
<SearchBarInput
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,19 @@ export function initializeChromecast() {
|
||||||
const context = (
|
const context = (
|
||||||
window as any
|
window as any
|
||||||
).cast.framework.CastContext.getInstance();
|
).cast.framework.CastContext.getInstance();
|
||||||
context.setOptions({
|
const options: any = {
|
||||||
receiverApplicationId: (window as any).chrome?.cast?.media
|
receiverApplicationId: (window as any).chrome?.cast?.media
|
||||||
?.DEFAULT_MEDIA_RECEIVER_APP_ID,
|
?.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) {
|
} catch (e) {
|
||||||
console.warn("Chromecast initialization error:", e);
|
console.warn("Chromecast initialization error:", e);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue