mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
remove option added to libitems in library
This commit is contained in:
parent
7ad69b7646
commit
46c18dea2a
2 changed files with 21 additions and 4 deletions
|
|
@ -8,10 +8,11 @@ const MetaItem = require('stremio/common/MetaItem');
|
||||||
const OPTIONS = [
|
const OPTIONS = [
|
||||||
{ label: 'Play', value: 'play' },
|
{ label: 'Play', value: 'play' },
|
||||||
{ label: 'Details', value: 'details' },
|
{ label: 'Details', value: 'details' },
|
||||||
{ label: 'Dismiss', value: 'dismiss' }
|
{ label: 'Dismiss', value: 'dismiss' },
|
||||||
|
{ label: 'Remove', value: 'remove' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const LibItem = ({ id, ...props }) => {
|
const LibItem = ({ id, removable, ...props }) => {
|
||||||
const { core } = useServices();
|
const { core } = useServices();
|
||||||
const options = React.useMemo(() => {
|
const options = React.useMemo(() => {
|
||||||
return OPTIONS.filter(({ value }) => {
|
return OPTIONS.filter(({ value }) => {
|
||||||
|
|
@ -22,9 +23,11 @@ const LibItem = ({ id, ...props }) => {
|
||||||
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 'dismiss':
|
case 'dismiss':
|
||||||
return typeof id === 'string' && props.progress !== null && !isNaN(props.progress);
|
return typeof id === 'string' && props.progress !== null && !isNaN(props.progress);
|
||||||
|
case 'remove':
|
||||||
|
return typeof id === 'string' && removable;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [id, props.progress, props.deepLinks]);
|
}, [id, removable, props.progress, props.deepLinks]);
|
||||||
const optionOnSelect = React.useCallback((event) => {
|
const optionOnSelect = React.useCallback((event) => {
|
||||||
if (typeof props.optionOnSelect === 'function') {
|
if (typeof props.optionOnSelect === 'function') {
|
||||||
props.optionOnSelect(event);
|
props.optionOnSelect(event);
|
||||||
|
|
@ -61,6 +64,19 @@ const LibItem = ({ id, ...props }) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'remove': {
|
||||||
|
if (typeof id === 'string') {
|
||||||
|
core.transport.dispatch({
|
||||||
|
action: 'Ctx',
|
||||||
|
args: {
|
||||||
|
action: 'RemoveFromLibrary',
|
||||||
|
args: id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +93,7 @@ const LibItem = ({ id, ...props }) => {
|
||||||
|
|
||||||
LibItem.propTypes = {
|
LibItem.propTypes = {
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
|
removable: PropTypes.bool,
|
||||||
progress: PropTypes.number,
|
progress: PropTypes.number,
|
||||||
deepLinks: PropTypes.shape({
|
deepLinks: PropTypes.shape({
|
||||||
metaDetailsVideos: PropTypes.string,
|
metaDetailsVideos: PropTypes.string,
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ const Library = ({ model, urlParams, queryParams }) => {
|
||||||
:
|
:
|
||||||
<div className={styles['meta-items-container']}>
|
<div className={styles['meta-items-container']}>
|
||||||
{library.catalog.map((libItem, index) => (
|
{library.catalog.map((libItem, index) => (
|
||||||
<LibItem {...libItem} key={index} />
|
<LibItem {...libItem} removable={model === 'library'} key={index} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue