From 5e8ad2e996632d105abd5f80920a667320cec921 Mon Sep 17 00:00:00 2001 From: Jip Fr Date: Sun, 12 Mar 2023 22:19:13 +0100 Subject: [PATCH] Localization, center loading, create divider action, rename season/episode route in EpisodeSelectionPopout --- src/components/popout/FloatingCard.tsx | 2 +- src/setup/locales/en/translation.json | 7 + src/video/components/VideoPlayer.tsx | 3 +- src/video/components/VideoPlayerBase.tsx | 4 +- .../components/actions/DividerAction.tsx | 12 ++ .../popouts/CaptionSelectionPopout.tsx | 4 +- .../popouts/EpisodeSelectionPopout.tsx | 127 ++---------------- .../popouts/SourceSelectionPopout.tsx | 4 +- 8 files changed, 39 insertions(+), 124 deletions(-) create mode 100644 src/video/components/actions/DividerAction.tsx diff --git a/src/components/popout/FloatingCard.tsx b/src/components/popout/FloatingCard.tsx index 6cd0d363..8d894f16 100644 --- a/src/components/popout/FloatingCard.tsx +++ b/src/components/popout/FloatingCard.tsx @@ -172,7 +172,7 @@ export const FloatingCardView = { }, Content(props: { children: React.ReactNode; noSection?: boolean }) { return ( -
+
{props.noSection ? (
{props.children} diff --git a/src/setup/locales/en/translation.json b/src/setup/locales/en/translation.json index 8eb776ec..630709b6 100644 --- a/src/setup/locales/en/translation.json +++ b/src/setup/locales/en/translation.json @@ -75,6 +75,13 @@ "errors": { "loadingWentWong": "Something went wrong loading the episodes for {{seasonTitle}}", "embedsError": "Something went wrong loading the embeds for this thing that you like" + }, + "descriptions": { + "sources": "What provider do you want to use?", + "embeds": "Choose which video to view", + "seasons": "Choose which season you want to watch", + "episode": "Pick an episode", + "captions": "Choose a subtitle language" } }, "errors": { diff --git a/src/video/components/VideoPlayer.tsx b/src/video/components/VideoPlayer.tsx index dea6526f..f86a5161 100644 --- a/src/video/components/VideoPlayer.tsx +++ b/src/video/components/VideoPlayer.tsx @@ -28,6 +28,7 @@ import { PopoutProviderAction } from "@/video/components/popouts/PopoutProviderA import { ChromecastAction } from "@/video/components/actions/ChromecastAction"; import { CastingTextAction } from "@/video/components/actions/CastingTextAction"; import { SettingsAction } from "./actions/SettingsAction"; +import { DividerAction } from "./actions/DividerAction"; type Props = VideoPlayerBaseProps; @@ -150,7 +151,7 @@ export function VideoPlayer(props: Props) {
-
+ diff --git a/src/video/components/VideoPlayerBase.tsx b/src/video/components/VideoPlayerBase.tsx index 954bf0d1..57549729 100644 --- a/src/video/components/VideoPlayerBase.tsx +++ b/src/video/components/VideoPlayerBase.tsx @@ -27,7 +27,9 @@ function VideoPlayerBaseWithState(props: VideoPlayerBaseProps) { const children = typeof props.children === "function" - ? props.children({ isFullscreen: videoInterface.isFullscreen }) + ? props.children({ + isFullscreen: videoInterface.isFullscreen, + }) : props.children; // TODO move error boundary to only decorated, shouldn't have styling diff --git a/src/video/components/actions/DividerAction.tsx b/src/video/components/actions/DividerAction.tsx new file mode 100644 index 00000000..ac1090f7 --- /dev/null +++ b/src/video/components/actions/DividerAction.tsx @@ -0,0 +1,12 @@ +import { useVideoPlayerDescriptor } from "@/video/state/hooks"; +import { useMeta } from "@/video/state/logic/meta"; +import { MWMediaType } from "@/backend/metadata/types"; + +export function DividerAction() { + const descriptor = useVideoPlayerDescriptor(); + const meta = useMeta(descriptor); + + if (meta?.meta.meta.type !== MWMediaType.SERIES) return null; + + return
; +} diff --git a/src/video/components/popouts/CaptionSelectionPopout.tsx b/src/video/components/popouts/CaptionSelectionPopout.tsx index 43ed729f..d464e82e 100644 --- a/src/video/components/popouts/CaptionSelectionPopout.tsx +++ b/src/video/components/popouts/CaptionSelectionPopout.tsx @@ -51,8 +51,8 @@ export function CaptionSelectionPopout(props: { height={500} > props.router.navigate("/")} /> diff --git a/src/video/components/popouts/EpisodeSelectionPopout.tsx b/src/video/components/popouts/EpisodeSelectionPopout.tsx index 6d5bed39..61218170 100644 --- a/src/video/components/popouts/EpisodeSelectionPopout.tsx +++ b/src/video/components/popouts/EpisodeSelectionPopout.tsx @@ -22,7 +22,7 @@ export function EpisodeSelectionPopout() { media: string; }>(); const { t } = useTranslation(); - const { pageProps, navigate } = useFloatingRouter("/season/episodes"); + const { pageProps, navigate } = useFloatingRouter("/episodes"); const descriptor = useVideoPlayerDescriptor(); const meta = useMeta(descriptor); @@ -84,7 +84,7 @@ export function EpisodeSelectionPopout() { const setSeason = (id: string) => { requestSeason(id); setCurrentVisibleSeason({ seasonId: id }); - navigate("/season"); + navigate("/episodes"); }; const { watched } = useWatchedContext(); @@ -95,11 +95,11 @@ export function EpisodeSelectionPopout() { return ( <> - + navigate("/season")} + title={t("videoPlayer.popouts.seasons")} + description={t("videoPlayer.popouts.descriptions.seasons")} + goBack={() => navigate("/episodes")} backText={`To ${currentSeasonInfo?.title.toLowerCase()}`} /> @@ -116,16 +116,16 @@ export function EpisodeSelectionPopout() { : "No season"} - + navigate("/season/episodes")} + onClick={() => navigate("/episodes/seasons")} className="flex cursor-pointer items-center space-x-2 transition-colors duration-200 hover:text-white" > Other seasons @@ -146,7 +146,7 @@ export function EpisodeSelectionPopout() { className="text-xl text-bink-600" />

- {t("videoPLayer.popouts.errors.loadingWentWrong", { + {t("videoPlayer.popouts.errors.loadingWentWrong", { seasonTitle: currentSeasonInfo?.title?.toLowerCase(), })}

@@ -185,112 +185,5 @@ export function EpisodeSelectionPopout() {
- // - //
- // - //
- // - // - // {currentSeasonInfo?.title || ""} - // - // - // {t("videoPlayer.popouts.seasons")} - // - //
- //
- //
- // - // {currentSeasonInfo - // ? meta?.seasons?.map?.((season) => ( - // setSeason(season.id)} - // isOnDarkBackground - // > - // {season.title} - // - // )) - // : "No season"} - // - // - // {loading ? ( - //
- // - //
- // ) : error ? ( - //
- //
- // - //

- // {t("videoPLayer.popouts.errors.loadingWentWrong", { - // seasonTitle: currentSeasonInfo?.title?.toLowerCase(), - // })} - //

- //
- //
- // ) : ( - //
- // {currentSeasonEpisodes && currentSeasonInfo - // ? currentSeasonEpisodes.map((e) => ( - // { - // if (e.id === meta?.episode?.episodeId) - // controls.closePopout(); - // else setCurrent(currentSeasonInfo.id, e.id); - // }} - // percentageCompleted={ - // watched.items.find( - // (item) => - // item.item?.series?.seasonId === - // currentSeasonInfo.id && - // item.item?.series?.episodeId === e.id - // )?.percentage - // } - // > - // {t("videoPlayer.popouts.episode", { - // index: e.number, - // title: e.title, - // })} - // - // )) - // : "No episodes"} - //
- // )} - //
- //
- //
- //
); } diff --git a/src/video/components/popouts/SourceSelectionPopout.tsx b/src/video/components/popouts/SourceSelectionPopout.tsx index fe2d5ca2..9651b306 100644 --- a/src/video/components/popouts/SourceSelectionPopout.tsx +++ b/src/video/components/popouts/SourceSelectionPopout.tsx @@ -181,7 +181,7 @@ export function SourceSelectionPopout(props: { > props.router.navigate("/")} /> @@ -206,7 +206,7 @@ export function SourceSelectionPopout(props: { > props.router.navigate(`/${props.prefix}`)} />