From 65d0218f816462de6a0f665346ceebe29aee41b2 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 27 Oct 2023 22:12:03 +0200 Subject: [PATCH] removed old todos, disable captions on load --- src/components/player/atoms/settings/CaptionsView.tsx | 1 - src/components/player/hooks/useCaptions.ts | 4 ++-- src/components/player/hooks/useVolume.ts | 3 +-- src/pages/PlayerView.tsx | 7 +++++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/player/atoms/settings/CaptionsView.tsx b/src/components/player/atoms/settings/CaptionsView.tsx index 29fc0515..f23eb944 100644 --- a/src/components/player/atoms/settings/CaptionsView.tsx +++ b/src/components/player/atoms/settings/CaptionsView.tsx @@ -127,7 +127,6 @@ function CustomCaptionOption() { ); } -// TODO fix language names, some are unknown export function CaptionsView({ id }: { id: string }) { const router = useOverlayRouter(id); const lang = usePlayerStore((s) => s.caption.selected?.language); diff --git a/src/components/player/hooks/useCaptions.ts b/src/components/player/hooks/useCaptions.ts index b27deaa5..6d5635f2 100644 --- a/src/components/player/hooks/useCaptions.ts +++ b/src/components/player/hooks/useCaptions.ts @@ -81,8 +81,8 @@ export function useCaptions() { }, [lastSelectedLanguage, search, download]); const toggleLastUsed = useCallback(async () => { - if (!enabled) await downloadLastUsed(); - else disable(); + if (enabled) disable(); + else await downloadLastUsed(); }, [downloadLastUsed, disable, enabled]); return { diff --git a/src/components/player/hooks/useVolume.ts b/src/components/player/hooks/useVolume.ts index 0b9afa25..72831624 100644 --- a/src/components/player/hooks/useVolume.ts +++ b/src/components/player/hooks/useVolume.ts @@ -8,8 +8,7 @@ export function useVolume() { const display = usePlayerStore((s) => s.display); const setStoredVolume = useVolumeStore((s) => s.setVolume); - const toggleVolume = (_isKeyboardEvent = false) => { - // TODO use keyboard event + const toggleVolume = () => { let newVolume = 0; if (volume > 0) { diff --git a/src/pages/PlayerView.tsx b/src/pages/PlayerView.tsx index 777e32b4..5ea8751d 100644 --- a/src/pages/PlayerView.tsx +++ b/src/pages/PlayerView.tsx @@ -1,7 +1,9 @@ import { RunOutput } from "@movie-web/providers"; import { useCallback, useEffect, useState } from "react"; import { useHistory, useParams } from "react-router-dom"; +import { useEffectOnce } from "react-use"; +import { useCaptions } from "@/components/player/hooks/useCaptions"; import { usePlayer } from "@/components/player/hooks/usePlayer"; import { usePlayerMeta } from "@/components/player/hooks/usePlayerMeta"; import { convertRunoutputToSource } from "@/components/player/utils/convertRunoutputToSource"; @@ -30,6 +32,7 @@ export function PlayerView() { const { status, playMedia, reset, setScrapeNotFound } = usePlayer(); const { setPlayerMeta, scrapeMedia } = usePlayerMeta(); const backUrl = useLastNonPlayerLink(); + const { disable } = useCaptions(); const paramsData = JSON.stringify({ media: params.media, @@ -63,6 +66,10 @@ export function PlayerView() { [playMedia, startAtParam] ); + useEffectOnce(() => { + disable(); + }); + return ( {status === playerStatus.IDLE ? (