Compare commits

..

11 Commits
4.7.0 ... dev

Author SHA1 Message Date
Jorrin
f3dd80f42b Merge pull request #1150 from movie-web/fix/#962
decrease amount of margin of edit button on small screens
2024-04-22 22:45:07 +02:00
William Oldham
cfc74dfa78 Merge branch 'dev' into fix/#962 2024-04-22 21:15:23 +01:00
William Oldham
1a3144a872 Merge pull request #1153 from movie-web/feature/#754
Improve how to change seasons
2024-04-22 21:14:09 +01:00
Jorrin
ae81832037 improve how to change seasons 2024-04-22 20:26:54 +02:00
Jorrin
3da8955607 decrease amount of margin on small screens 2024-04-22 19:12:18 +02:00
William Oldham
9bd5f30f40 Merge pull request #1140 from movie-web/fix/#1118
fix tmdb 404 request
2024-04-20 10:37:58 +01:00
Jorrin
0a15bb2023 consistent returns 2024-04-20 11:36:38 +02:00
Jorrin
cfa3cfd072 check for undefined 2024-04-19 19:28:49 +02:00
Jorrin
5fbe5d1ff5 fix tmdb 404 request 2024-04-19 19:26:29 +02:00
William Oldham
4712d8fc5d Merge pull request #1122 from movie-web/fix/tmdb
Use vanilla AbortController for compatability
2024-04-15 20:13:55 +01:00
William Oldham
a9d80ddf24 Use vanilla AbortController for compat 2024-04-15 20:10:44 +01:00
5 changed files with 35 additions and 17 deletions

View File

@@ -278,7 +278,8 @@
"loadingError": "Error loading season", "loadingError": "Error loading season",
"loadingList": "Loading...", "loadingList": "Loading...",
"loadingTitle": "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": { "playback": {
"speedLabel": "Playback speed", "speedLabel": "Playback speed",

View File

@@ -153,6 +153,12 @@ const tmdbHeaders = {
Authorization: `Bearer ${apiKey}`, 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> { async function get<T>(url: string, params?: object): Promise<T> {
if (!apiKey) throw new Error("TMDB API key not set"); if (!apiKey) throw new Error("TMDB API key not set");
try { try {
@@ -162,7 +168,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
params: { params: {
...params, ...params,
}, },
signal: AbortSignal.timeout(5000), signal: abortOnTimeout(5000),
}); });
} catch (err) { } catch (err) {
return mwFetch<T>(encodeURI(url), { return mwFetch<T>(encodeURI(url), {
@@ -171,7 +177,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
params: { params: {
...params, ...params,
}, },
signal: AbortSignal.timeout(30000), signal: abortOnTimeout(30000),
}); });
} }
} }

View File

@@ -25,7 +25,7 @@ export function EditButton(props: EditButtonProps) {
> >
<span ref={parent}> <span ref={parent}>
{props.editing ? ( {props.editing ? (
<span className="mx-4 whitespace-nowrap"> <span className="mx-2 sm:mx-4 whitespace-nowrap">
{t("home.mediaList.stopEditing")} {t("home.mediaList.stopEditing")}
</span> </span>
) : ( ) : (

View File

@@ -212,9 +212,16 @@ function EpisodesView({
return ( return (
<Menu.CardWithScrollable> <Menu.CardWithScrollable>
<Menu.BackLink onClick={goBack}> <Menu.BackLink
onClick={goBack}
rightSide={
<span>
{loadingState?.value?.season.title || {loadingState?.value?.season.title ||
t("player.menus.episodes.loadingTitle")} t("player.menus.episodes.loadingTitle")}
</span>
}
>
{t("player.menus.episodes.seasons")}
</Menu.BackLink> </Menu.BackLink>
{content} {content}
</Menu.CardWithScrollable> </Menu.CardWithScrollable>

View File

@@ -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 () => { const state = useAsync(async () => {
if (isLastEpisode) { 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; if (data?.meta.type !== MWMediaType.SERIES) return null;
return data.meta.seasons; return data.meta.seasons;
} }
@@ -60,13 +64,14 @@ function useSeasons(mediaId: string, isLastEpisode: boolean = false) {
function useNextSeasonEpisode( function useNextSeasonEpisode(
nextSeason: MWSeasonMeta | undefined, nextSeason: MWSeasonMeta | undefined,
mediaId: string, mediaId: string | undefined,
) { ) {
const state = useAsync(async () => { const state = useAsync(async () => {
if (nextSeason) { if (nextSeason) {
if (!mediaId) return null;
const data = await getMetaFromId( const data = await getMetaFromId(
MWMediaType.SERIES, MWMediaType.SERIES,
mediaId ?? "", mediaId,
nextSeason?.id, nextSeason?.id,
); );
if (data?.meta.type !== MWMediaType.SERIES) return null; if (data?.meta.type !== MWMediaType.SERIES) return null;
@@ -106,18 +111,17 @@ export function NextEpisodeButton(props: {
const enableAutoplay = usePreferencesStore((s) => s.enableAutoplay); const enableAutoplay = usePreferencesStore((s) => s.enableAutoplay);
const isLastEpisode = 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( const nextSeason = seasons.value?.find(
(season) => season.number === (meta?.season?.number ?? 0) + 1, (season) => season.number === (meta?.season?.number ?? 0) + 1,
); );
const nextSeasonEpisode = useNextSeasonEpisode( const nextSeasonEpisode = useNextSeasonEpisode(nextSeason, meta?.tmdbId);
nextSeason,
meta?.tmdbId ?? "",
);
let show = false; let show = false;
const hasAutoplayed = useRef(false); const hasAutoplayed = useRef(false);