mirror of
https://github.com/movie-web/movie-web.git
synced 2024-06-03 04:28:45 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f3dd80f42b | ||
|
cfc74dfa78 | ||
|
1a3144a872 | ||
|
ae81832037 | ||
|
3da8955607 | ||
|
9bd5f30f40 | ||
|
0a15bb2023 | ||
|
cfa3cfd072 | ||
|
5fbe5d1ff5 | ||
|
4712d8fc5d | ||
|
a9d80ddf24 |
|
@ -278,7 +278,8 @@
|
|||
"loadingError": "Error loading season",
|
||||
"loadingList": "Loading...",
|
||||
"loadingTitle": "Loading...",
|
||||
"unairedEpisodes": "One or more episodes in this season have been disabled because they haven't been aired yet."
|
||||
"unairedEpisodes": "One or more episodes in this season have been disabled because they haven't been aired yet.",
|
||||
"seasons": "Seasons"
|
||||
},
|
||||
"playback": {
|
||||
"speedLabel": "Playback speed",
|
||||
|
|
|
@ -153,6 +153,12 @@ const tmdbHeaders = {
|
|||
Authorization: `Bearer ${apiKey}`,
|
||||
};
|
||||
|
||||
function abortOnTimeout(timeout: number): AbortSignal {
|
||||
const controller = new AbortController();
|
||||
setTimeout(() => controller.abort(), timeout);
|
||||
return controller.signal;
|
||||
}
|
||||
|
||||
async function get<T>(url: string, params?: object): Promise<T> {
|
||||
if (!apiKey) throw new Error("TMDB API key not set");
|
||||
try {
|
||||
|
@ -162,7 +168,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
|
|||
params: {
|
||||
...params,
|
||||
},
|
||||
signal: AbortSignal.timeout(5000),
|
||||
signal: abortOnTimeout(5000),
|
||||
});
|
||||
} catch (err) {
|
||||
return mwFetch<T>(encodeURI(url), {
|
||||
|
@ -171,7 +177,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
|
|||
params: {
|
||||
...params,
|
||||
},
|
||||
signal: AbortSignal.timeout(30000),
|
||||
signal: abortOnTimeout(30000),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export function EditButton(props: EditButtonProps) {
|
|||
>
|
||||
<span ref={parent}>
|
||||
{props.editing ? (
|
||||
<span className="mx-4 whitespace-nowrap">
|
||||
<span className="mx-2 sm:mx-4 whitespace-nowrap">
|
||||
{t("home.mediaList.stopEditing")}
|
||||
</span>
|
||||
) : (
|
||||
|
|
|
@ -212,9 +212,16 @@ function EpisodesView({
|
|||
|
||||
return (
|
||||
<Menu.CardWithScrollable>
|
||||
<Menu.BackLink onClick={goBack}>
|
||||
{loadingState?.value?.season.title ||
|
||||
t("player.menus.episodes.loadingTitle")}
|
||||
<Menu.BackLink
|
||||
onClick={goBack}
|
||||
rightSide={
|
||||
<span>
|
||||
{loadingState?.value?.season.title ||
|
||||
t("player.menus.episodes.loadingTitle")}
|
||||
</span>
|
||||
}
|
||||
>
|
||||
{t("player.menus.episodes.seasons")}
|
||||
</Menu.BackLink>
|
||||
{content}
|
||||
</Menu.CardWithScrollable>
|
||||
|
|
|
@ -46,10 +46,14 @@ function Button(props: {
|
|||
);
|
||||
}
|
||||
|
||||
function useSeasons(mediaId: string, isLastEpisode: boolean = false) {
|
||||
function useSeasons(
|
||||
mediaId: string | undefined,
|
||||
isLastEpisode: boolean = false,
|
||||
) {
|
||||
const state = useAsync(async () => {
|
||||
if (isLastEpisode) {
|
||||
const data = await getMetaFromId(MWMediaType.SERIES, mediaId ?? "");
|
||||
if (!mediaId) return null;
|
||||
const data = await getMetaFromId(MWMediaType.SERIES, mediaId);
|
||||
if (data?.meta.type !== MWMediaType.SERIES) return null;
|
||||
return data.meta.seasons;
|
||||
}
|
||||
|
@ -60,13 +64,14 @@ function useSeasons(mediaId: string, isLastEpisode: boolean = false) {
|
|||
|
||||
function useNextSeasonEpisode(
|
||||
nextSeason: MWSeasonMeta | undefined,
|
||||
mediaId: string,
|
||||
mediaId: string | undefined,
|
||||
) {
|
||||
const state = useAsync(async () => {
|
||||
if (nextSeason) {
|
||||
if (!mediaId) return null;
|
||||
const data = await getMetaFromId(
|
||||
MWMediaType.SERIES,
|
||||
mediaId ?? "",
|
||||
mediaId,
|
||||
nextSeason?.id,
|
||||
);
|
||||
if (data?.meta.type !== MWMediaType.SERIES) return null;
|
||||
|
@ -106,18 +111,17 @@ export function NextEpisodeButton(props: {
|
|||
const enableAutoplay = usePreferencesStore((s) => s.enableAutoplay);
|
||||
|
||||
const isLastEpisode =
|
||||
meta?.episode?.number === meta?.episodes?.at(-1)?.number;
|
||||
!meta?.episode?.number || !meta?.episodes?.at(-1)?.number
|
||||
? false
|
||||
: meta.episode.number === meta.episodes.at(-1)!.number;
|
||||
|
||||
const seasons = useSeasons(meta?.tmdbId ?? "", isLastEpisode);
|
||||
const seasons = useSeasons(meta?.tmdbId, isLastEpisode);
|
||||
|
||||
const nextSeason = seasons.value?.find(
|
||||
(season) => season.number === (meta?.season?.number ?? 0) + 1,
|
||||
);
|
||||
|
||||
const nextSeasonEpisode = useNextSeasonEpisode(
|
||||
nextSeason,
|
||||
meta?.tmdbId ?? "",
|
||||
);
|
||||
const nextSeasonEpisode = useNextSeasonEpisode(nextSeason, meta?.tmdbId);
|
||||
|
||||
let show = false;
|
||||
const hasAutoplayed = useRef(false);
|
||||
|
|
Loading…
Reference in New Issue
Block a user