mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 11:42:05 +00:00
fix(EpisodePicker): handle season 0 as value
This commit is contained in:
parent
461c9d3d53
commit
39f168a34c
2 changed files with 5 additions and 3 deletions
|
|
@ -21,7 +21,7 @@ type Props = InputHTMLAttributes<HTMLInputElement> & {
|
||||||
};
|
};
|
||||||
|
|
||||||
const NumberInput = forwardRef<HTMLInputElement, Props>(({ defaultValue, ...props }, ref) => {
|
const NumberInput = forwardRef<HTMLInputElement, Props>(({ defaultValue, ...props }, ref) => {
|
||||||
const [value, setValue] = useState(defaultValue || 1);
|
const [value, setValue] = useState(defaultValue || 0);
|
||||||
const onKeyDown = useCallback((event: KeyboardEvent<HTMLInputElement>) => {
|
const onKeyDown = useCallback((event: KeyboardEvent<HTMLInputElement>) => {
|
||||||
props.onKeyDown && props.onKeyDown(event);
|
props.onKeyDown && props.onKeyDown(event);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ export const EpisodePicker = ({ className, seriesId, onSubmit }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [initialSeason, initialEpisode] = React.useMemo(() => {
|
const [initialSeason, initialEpisode] = React.useMemo(() => {
|
||||||
const [, season, episode] = seriesId ? seriesId.split(':') : [];
|
const [, season, episode] = seriesId ? seriesId.split(':') : [];
|
||||||
return [parseInt(season || '1'), parseInt(episode || '1')];
|
const initialSeason = isNaN(parseInt(season)) ? 1 : parseInt(season);
|
||||||
|
const initialEpisode = isNaN(parseInt(episode)) ? 1 : parseInt(episode);
|
||||||
|
return [initialSeason, initialEpisode];
|
||||||
}, [seriesId]);
|
}, [seriesId]);
|
||||||
const seasonRef = useRef(null);
|
const seasonRef = useRef(null);
|
||||||
const episodeRef = useRef(null);
|
const episodeRef = useRef(null);
|
||||||
|
|
@ -26,7 +28,7 @@ export const EpisodePicker = ({ className, seriesId, onSubmit }: Props) => {
|
||||||
}, [onSubmit, seasonRef, episodeRef]);
|
}, [onSubmit, seasonRef, episodeRef]);
|
||||||
|
|
||||||
return <div className={className}>
|
return <div className={className}>
|
||||||
<NumberInput ref={seasonRef} min={1} label={t('SEASON')} defaultValue={initialSeason} showButtons />
|
<NumberInput ref={seasonRef} min={0} label={t('SEASON')} defaultValue={initialSeason} showButtons />
|
||||||
<NumberInput ref={episodeRef} min={1} label={t('EPISODE')} defaultValue={initialEpisode} showButtons />
|
<NumberInput ref={episodeRef} min={1} label={t('EPISODE')} defaultValue={initialEpisode} showButtons />
|
||||||
<Button className={styles['button-container']} onClick={handleSubmit}>{t('SIDEBAR_SHOW_STREAMS')}</Button>
|
<Button className={styles['button-container']} onClick={handleSubmit}>{t('SIDEBAR_SHOW_STREAMS')}</Button>
|
||||||
</div>;
|
</div>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue