Merge pull request #704 from ArtificialSloth/feat/LibItem-behavior
Some checks are pending
Build / build (push) Waiting to run

Library: Improve LibraryItem behaviour hints
This commit is contained in:
Timothy Z. 2026-03-02 13:41:36 +02:00 committed by GitHub
commit 8367dce25d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 24 deletions

View file

@ -5,24 +5,11 @@ const PropTypes = require('prop-types');
const { useServices } = require('stremio/services'); const { useServices } = require('stremio/services');
const LibItem = require('stremio/components/LibItem'); const LibItem = require('stremio/components/LibItem');
const ContinueWatchingItem = ({ _id, notifications, deepLinks, ...props }) => { const ContinueWatchingItem = ({ _id, notifications, ...props }) => {
const { core } = useServices(); const { core } = useServices();
const onClick = React.useCallback(() => {
if (deepLinks?.metaDetailsVideos ?? deepLinks?.metaDetailsStreams) {
window.location = deepLinks?.metaDetailsVideos ?? deepLinks?.metaDetailsStreams;
}
}, [deepLinks]);
const onPlayClick = React.useCallback((event) => {
event.stopPropagation();
if (deepLinks?.player ?? deepLinks?.metaDetailsStreams ?? deepLinks?.metaDetailsVideos) {
window.location = deepLinks?.player ?? deepLinks?.metaDetailsStreams ?? deepLinks?.metaDetailsVideos;
}
}, [deepLinks]);
const onDismissClick = React.useCallback((event) => { const onDismissClick = React.useCallback((event) => {
event.stopPropagation(); event.preventDefault();
if (typeof _id === 'string') { if (typeof _id === 'string') {
core.transport.dispatch({ core.transport.dispatch({
action: 'Ctx', action: 'Ctx',
@ -47,8 +34,6 @@ const ContinueWatchingItem = ({ _id, notifications, deepLinks, ...props }) => {
_id={_id} _id={_id}
posterChangeCursor={true} posterChangeCursor={true}
notifications={notifications} notifications={notifications}
onClick={onClick}
onPlayClick={onPlayClick}
onDismissClick={onDismissClick} onDismissClick={onDismissClick}
/> />
); );

View file

@ -29,7 +29,7 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
case 'details': case 'details':
return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string'); return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string');
case 'watched': case 'watched':
return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string'); return typeof watched !== 'undefined' && props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string');
case 'dismiss': case 'dismiss':
return typeof _id === 'string' && props.progress !== null && !isNaN(props.progress) && props.progress > 0; return typeof _id === 'string' && props.progress !== null && !isNaN(props.progress) && props.progress > 0;
case 'remove': case 'remove':
@ -119,6 +119,16 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
} }
}, [_id, props.deepLinks, props.optionOnSelect]); }, [_id, props.deepLinks, props.optionOnSelect]);
const onPlayClick = React.useMemo(() => {
if (props.deepLinks && typeof props.deepLinks.player === 'string') {
return (event) => {
event.preventDefault();
window.location = props.deepLinks.player;
};
}
return null;
}, [props.deepLinks]);
return ( return (
<MetaItem <MetaItem
{...props} {...props}
@ -126,6 +136,7 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
newVideos={newVideos} newVideos={newVideos}
options={options} options={options}
optionOnSelect={optionOnSelect} optionOnSelect={optionOnSelect}
onPlayClick={onPlayClick}
/> />
); );
}; };

View file

@ -18,14 +18,14 @@ const MetaItem = React.memo(({ className, type, name, poster, posterShape, poste
const [menuOpen, onMenuOpen, onMenuClose] = useBinaryState(false); const [menuOpen, onMenuOpen, onMenuClose] = useBinaryState(false);
const href = React.useMemo(() => { const href = React.useMemo(() => {
return deepLinks ? return deepLinks ?
typeof deepLinks.player === 'string' ? typeof deepLinks.metaDetailsStreams === 'string' ?
deepLinks.player deepLinks.metaDetailsStreams
: :
typeof deepLinks.metaDetailsStreams === 'string' ? typeof deepLinks.metaDetailsVideos === 'string' ?
deepLinks.metaDetailsStreams deepLinks.metaDetailsVideos
: :
typeof deepLinks.metaDetailsVideos === 'string' ? typeof deepLinks.player === 'string' ?
deepLinks.metaDetailsVideos deepLinks.player
: :
null null
: :