mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-16 13:12:23 +00:00
fix: correctly use track for selection
This commit is contained in:
parent
3c417a3306
commit
0d1358d6cb
2 changed files with 6 additions and 3 deletions
|
|
@ -39,6 +39,9 @@ const SubtitleVariant = ({ track, selected, onSelect }: Props) => {
|
||||||
const variantLabel = hasValidLabel(track.label) ? track.label : languages.label(track.lang);
|
const variantLabel = hasValidLabel(track.label) ? track.label : languages.label(track.lang);
|
||||||
const downloadFileName = hasValidLabel(track.label) ? track.label : `subtitle-${track.lang || 'unknown'}`;
|
const downloadFileName = hasValidLabel(track.label) ? track.label : `subtitle-${track.lang || 'unknown'}`;
|
||||||
const canCopyUrl = typeof downloadUrl === 'string' && !downloadUrl.startsWith('blob:');
|
const canCopyUrl = typeof downloadUrl === 'string' && !downloadUrl.startsWith('blob:');
|
||||||
|
const hoverTitle = hasValidLabel(track.label)
|
||||||
|
? track.label
|
||||||
|
: downloadUrl?.split('/').pop()?.split('?')[0] || variantLabel;
|
||||||
|
|
||||||
const onSelectClick = useCallback(() => {
|
const onSelectClick = useCallback(() => {
|
||||||
onSelect(track);
|
onSelect(track);
|
||||||
|
|
@ -65,7 +68,7 @@ const SubtitleVariant = ({ track, selected, onSelect }: Props) => {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
ref={buttonRef}
|
ref={buttonRef}
|
||||||
title={variantLabel}
|
title={hoverTitle}
|
||||||
onClick={onSelectClick}
|
onClick={onSelectClick}
|
||||||
className={classNames(styles['variant-option'], { 'selected': selected })}
|
className={classNames(styles['variant-option'], { 'selected': selected })}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -106,11 +106,11 @@ const SubtitlesMenu = React.memo(React.forwardRef((props, ref) => {
|
||||||
const subtitlesTrackOnSelect = React.useCallback((track) => {
|
const subtitlesTrackOnSelect = React.useCallback((track) => {
|
||||||
if (track.embedded) {
|
if (track.embedded) {
|
||||||
if (typeof props.onSubtitlesTrackSelected === 'function') {
|
if (typeof props.onSubtitlesTrackSelected === 'function') {
|
||||||
props.onSubtitlesTrackSelected(track.id);
|
props.onSubtitlesTrackSelected(track);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof props.onExtraSubtitlesTrackSelected === 'function') {
|
if (typeof props.onExtraSubtitlesTrackSelected === 'function') {
|
||||||
props.onExtraSubtitlesTrackSelected(track.id);
|
props.onExtraSubtitlesTrackSelected(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [props.onSubtitlesTrackSelected, props.onExtraSubtitlesTrackSelected]);
|
}, [props.onSubtitlesTrackSelected, props.onExtraSubtitlesTrackSelected]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue