From 6274115f8f71a5b891b4c3d319ac46fd6d0f508d Mon Sep 17 00:00:00 2001 From: Botzy Date: Wed, 12 Feb 2025 13:55:34 +0200 Subject: [PATCH] refactor(EpisodePicker): simplify setting season and episode initial state --- .../StreamsList/EpisodePicker/EpisodePicker.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/routes/MetaDetails/StreamsList/EpisodePicker/EpisodePicker.tsx b/src/routes/MetaDetails/StreamsList/EpisodePicker/EpisodePicker.tsx index 45746d790..2932d00e4 100644 --- a/src/routes/MetaDetails/StreamsList/EpisodePicker/EpisodePicker.tsx +++ b/src/routes/MetaDetails/StreamsList/EpisodePicker/EpisodePicker.tsx @@ -16,14 +16,8 @@ const EpisodePicker = ({ className, onSubmit }: Props) => { const splitPath = window.location.hash.split('/'); const videoId = decodeURIComponent(splitPath[splitPath.length - 1]); const [, pathSeason, pathEpisode] = videoId ? videoId.split(':') : []; - const [season, setSeason] = React.useState(() => { - const initialSeason = isNaN(parseInt(pathSeason)) ? 0 : parseInt(pathSeason); - return initialSeason; - }); - const [episode, setEpisode] = React.useState(() => { - const initialEpisode = isNaN(parseInt(pathEpisode)) ? 1 : parseInt(pathEpisode); - return initialEpisode; - }); + const [season, setSeason] = React.useState(isNaN(parseInt(pathSeason)) ? 0 : parseInt(pathSeason)); + const [episode, setEpisode] = React.useState(isNaN(parseInt(pathEpisode)) ? 1 : parseInt(pathEpisode)); const handleSeasonChange = (value: number) => setSeason(!isNaN(value) ? value : 0); const handleEpisodeChange = (value: number) => setEpisode(!isNaN(value) ? value : 1);