mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
copy infohash to clipboard when right clicking the search result. toast.
This commit is contained in:
parent
ee5821da33
commit
10c878871f
2 changed files with 23 additions and 3 deletions
|
|
@ -74,12 +74,18 @@ const Stream = ({ className, videoId, videoReleased, addonName, name, descriptio
|
|||
}
|
||||
}, [props.onClick, profile.settings, markVideoAsWatched]);
|
||||
|
||||
const onContextMenu = React.useCallback((event) => {
|
||||
if (typeof props.onContextMenu === 'function') {
|
||||
props.onContextMenu(event);
|
||||
}
|
||||
}, [props.onContextMenu]);
|
||||
|
||||
const renderThumbnailFallback = React.useCallback(() => (
|
||||
<Icon className={styles['placeholder-icon']} name={'ic_broken_link'} />
|
||||
), []);
|
||||
|
||||
return (
|
||||
<Button className={classnames(className, styles['stream-container'])} title={addonName} href={href} download={download} target={target} onClick={onClick}>
|
||||
<Button className={classnames(className, styles['stream-container'])} title={addonName} href={href} download={download} target={target} onClick={onClick} onContextMenu={onContextMenu}>
|
||||
<div className={styles['info-container']}>
|
||||
{
|
||||
typeof thumbnail === 'string' && thumbnail.length > 0 ?
|
||||
|
|
@ -140,7 +146,8 @@ Stream.propTypes = {
|
|||
})
|
||||
})
|
||||
}),
|
||||
onClick: PropTypes.func
|
||||
onClick: PropTypes.func,
|
||||
onContextMenu: PropTypes.func
|
||||
};
|
||||
|
||||
module.exports = Stream;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const PropTypes = require('prop-types');
|
|||
const classnames = require('classnames');
|
||||
const { useTranslation } = require('react-i18next');
|
||||
const { default: Icon } = require('@stremio/stremio-icons/react');
|
||||
const { Button, Image, Multiselect } = require('stremio/common');
|
||||
const { Button, Image, Multiselect, useToast } = require('stremio/common');
|
||||
const { useServices } = require('stremio/services');
|
||||
const Stream = require('./Stream');
|
||||
const styles = require('./styles');
|
||||
|
|
@ -15,6 +15,7 @@ const ALL_ADDONS_KEY = 'ALL';
|
|||
const StreamsList = ({ className, video, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
const { core } = useServices();
|
||||
const toast = useToast();
|
||||
const [selectedAddon, setSelectedAddon] = React.useState(ALL_ADDONS_KEY);
|
||||
const onAddonSelected = React.useCallback((event) => {
|
||||
setSelectedAddon(event.value);
|
||||
|
|
@ -41,6 +42,17 @@ const StreamsList = ({ className, video, ...props }) => {
|
|||
}
|
||||
});
|
||||
},
|
||||
onContextMenu: (e) => {
|
||||
e.preventDefault();
|
||||
if(stream?.infoHash && navigator?.clipboard) {
|
||||
stream?.infoHash && navigator?.clipboard?.writeText(stream.infoHash);
|
||||
toast.show({
|
||||
type: 'success',
|
||||
title: 'Copied infohash to clipboard',
|
||||
timeout: 4000
|
||||
});
|
||||
}
|
||||
},
|
||||
addonName: streams.addon.manifest.name
|
||||
}))
|
||||
};
|
||||
|
|
@ -146,6 +158,7 @@ const StreamsList = ({ className, video, ...props }) => {
|
|||
progress={stream.progress}
|
||||
deepLinks={stream.deepLinks}
|
||||
onClick={stream.onClick}
|
||||
onContextMenu={stream.onContextMenu}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue