mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
attempted to undo IDE auto formatting
This commit is contained in:
parent
ad58ab069e
commit
ff41ff2997
1 changed files with 72 additions and 104 deletions
|
|
@ -4,33 +4,14 @@ const React = require('react');
|
|||
const PropTypes = require('prop-types');
|
||||
const classnames = require('classnames');
|
||||
const { default: Icon } = require('@stremio/stremio-icons/react');
|
||||
const {
|
||||
Button,
|
||||
Image,
|
||||
useProfile,
|
||||
platform,
|
||||
useToast,
|
||||
Popup,
|
||||
useBinaryState,
|
||||
} = require('stremio/common');
|
||||
const { Button, Image, useProfile, platform, useToast, Popup, useBinaryState } = require('stremio/common');
|
||||
const { useServices } = require('stremio/services');
|
||||
const StreamPlaceholder = require('./StreamPlaceholder');
|
||||
const { t } = require('i18next');
|
||||
|
||||
const styles = require('./styles');
|
||||
|
||||
const Stream = ({
|
||||
className,
|
||||
videoId,
|
||||
videoReleased,
|
||||
addonName,
|
||||
name,
|
||||
description,
|
||||
thumbnail,
|
||||
progress,
|
||||
deepLinks,
|
||||
...props
|
||||
}) => {
|
||||
const Stream = ({ className, videoId, videoReleased, addonName, name, description, thumbnail, progress, deepLinks, ...props }) => {
|
||||
const profile = useProfile();
|
||||
const toast = useToast();
|
||||
const { core } = useServices();
|
||||
|
|
@ -69,27 +50,36 @@ const Stream = ({
|
|||
}, []);
|
||||
|
||||
const href = React.useMemo(() => {
|
||||
return deepLinks
|
||||
? deepLinks.externalPlayer
|
||||
? deepLinks.externalPlayer.web
|
||||
? deepLinks.externalPlayer.web
|
||||
: deepLinks.externalPlayer.openPlayer
|
||||
? deepLinks.externalPlayer.openPlayer[platform.name]
|
||||
? deepLinks.externalPlayer.openPlayer[platform.name]
|
||||
: deepLinks.externalPlayer.playlist
|
||||
: deepLinks.player
|
||||
: deepLinks.player
|
||||
: null;
|
||||
return deepLinks ?
|
||||
deepLinks.externalPlayer ?
|
||||
deepLinks.externalPlayer.web ?
|
||||
deepLinks.externalPlayer.web
|
||||
:
|
||||
deepLinks.externalPlayer.openPlayer ?
|
||||
deepLinks.externalPlayer.openPlayer[platform.name] ?
|
||||
deepLinks.externalPlayer.openPlayer[platform.name]
|
||||
:
|
||||
deepLinks.externalPlayer.playlist
|
||||
:
|
||||
deepLinks.player
|
||||
:
|
||||
deepLinks.player
|
||||
:
|
||||
null;
|
||||
}, [deepLinks]);
|
||||
|
||||
const download = React.useMemo(() => {
|
||||
return href === deepLinks?.externalPlayer?.playlist
|
||||
? deepLinks.externalPlayer.fileName
|
||||
: null;
|
||||
return href === deepLinks?.externalPlayer?.playlist ?
|
||||
deepLinks.externalPlayer.fileName
|
||||
:
|
||||
null;
|
||||
}, [href, deepLinks]);
|
||||
|
||||
const target = React.useMemo(() => {
|
||||
return href === deepLinks?.externalPlayer?.web ? '_blank' : null;
|
||||
return href === deepLinks?.externalPlayer?.web ?
|
||||
'_blank'
|
||||
:
|
||||
null;
|
||||
}, [href, deepLinks]);
|
||||
|
||||
const markVideoAsWatched = React.useCallback(() => {
|
||||
|
|
@ -98,28 +88,27 @@ const Stream = ({
|
|||
action: 'MetaDetails',
|
||||
args: {
|
||||
action: 'MarkVideoAsWatched',
|
||||
args: [{ id: videoId, released: videoReleased }, true],
|
||||
},
|
||||
args: [{ id: videoId, released: videoReleased }, true]
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [videoId, videoReleased]);
|
||||
|
||||
const onClick = React.useCallback(
|
||||
(event) => {
|
||||
if (profile.settings.playerType !== null) {
|
||||
markVideoAsWatched();
|
||||
toast.show({
|
||||
type: 'success',
|
||||
title: 'Stream opened in external player',
|
||||
timeout: 4000,
|
||||
});
|
||||
}
|
||||
const onClick = React.useCallback((event) => {
|
||||
if (profile.settings.playerType !== null) {
|
||||
markVideoAsWatched();
|
||||
toast.show({
|
||||
type: 'success',
|
||||
title: 'Stream opened in external player',
|
||||
timeout: 4000
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof props.onClick === 'function') {
|
||||
props.onClick(event);
|
||||
}
|
||||
},
|
||||
[props.onClick, profile.settings, markVideoAsWatched]
|
||||
if (typeof props.onClick === 'function') {
|
||||
props.onClick(event);
|
||||
}
|
||||
},
|
||||
[props.onClick, profile.settings, markVideoAsWatched]
|
||||
);
|
||||
|
||||
const copyMagneticLinkToClipboard = React.useCallback((event) => {
|
||||
|
|
@ -129,69 +118,48 @@ const Stream = ({
|
|||
toast.show({
|
||||
type: 'success',
|
||||
title: t('PLAYER_COPY_DOWNLOAD_LINK_SUCCESS'),
|
||||
timeout: 4000,
|
||||
timeout: 4000
|
||||
});
|
||||
}
|
||||
closeMenu();
|
||||
}, []);
|
||||
|
||||
const renderThumbnailFallback = React.useCallback(
|
||||
() => (
|
||||
<Icon className={styles['placeholder-icon']} name={'ic_broken_link'} />
|
||||
),
|
||||
[]
|
||||
);
|
||||
const renderThumbnailFallback = React.useCallback(() => (
|
||||
<Icon className={styles['placeholder-icon']} name={'ic_broken_link'} />
|
||||
), []);
|
||||
|
||||
const renderLabel = React.useMemo(
|
||||
() =>
|
||||
function renderLabel({ className, thumbnail, progress, children, ...props }) {
|
||||
return (
|
||||
<Button
|
||||
className={classnames(className, styles['stream-container'])}
|
||||
title={addonName}
|
||||
download={download}
|
||||
target={target}
|
||||
onClick={onClick}
|
||||
{...props}
|
||||
>
|
||||
<Button className={classnames(className, styles['stream-container'])} title={addonName} href={href} download={download} target={target} onClick={onClick} {...props}>
|
||||
<div className={styles['info-container']}>
|
||||
{typeof thumbnail === 'string' && thumbnail.length > 0 ? (
|
||||
<div
|
||||
className={styles['thumbnail-container']}
|
||||
title={name || addonName}
|
||||
>
|
||||
<Image
|
||||
className={styles['thumbnail']}
|
||||
src={thumbnail}
|
||||
alt={' '}
|
||||
renderFallback={renderThumbnailFallback}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className={styles['addon-name-container']}
|
||||
title={name || addonName}
|
||||
>
|
||||
<div className={styles['addon-name']}>
|
||||
{name || addonName}
|
||||
{
|
||||
typeof thumbnail === 'string' && thumbnail.length > 0 ?
|
||||
<div className={styles['thumbnail-container']} title={name || addonName}>
|
||||
<Image
|
||||
className={styles['thumbnail']}
|
||||
src={thumbnail}
|
||||
alt={' '}
|
||||
renderFallback={renderThumbnailFallback}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{progress !== null && !isNaN(progress) && progress > 0 ? (
|
||||
<div className={styles['progress-bar-container']}>
|
||||
<div
|
||||
className={styles['progress-bar']}
|
||||
style={{ width: `${progress}%` }}
|
||||
/>
|
||||
<div className={styles['progress-bar-background']} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div
|
||||
className={styles['description-container']}
|
||||
title={description}
|
||||
>
|
||||
{description}
|
||||
:
|
||||
<div className={styles['addon-name-container']} title={name || addonName}>
|
||||
<div className={styles['addon-name']}>{name || addonName}</div>
|
||||
</div>
|
||||
}
|
||||
{
|
||||
progress !== null && !isNaN(progress) && progress > 0 ?
|
||||
<div className={styles['progress-bar-container']}>
|
||||
<div className={styles['progress-bar']} style={{ width: `${progress}%` }} />
|
||||
<div className={styles['progress-bar-background']} />
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
<div className={styles['description-container']} title={description}>{description}</div>
|
||||
<Icon className={styles['icon']} name={'play'} />
|
||||
{children}
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue