refactor: simplify handling on the libitem

This commit is contained in:
Timothy Z. 2026-03-02 13:38:45 +02:00
parent e26c33fe33
commit 68c0a4fb13

View file

@ -119,11 +119,14 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
}
}, [_id, props.deepLinks, props.optionOnSelect]);
const onPlayClick = React.useCallback((event) => {
const onPlayClick = React.useMemo(() => {
if (props.deepLinks && typeof props.deepLinks.player === 'string') {
event.preventDefault();
window.location = props.deepLinks.player;
return (event) => {
event.preventDefault();
window.location = props.deepLinks.player;
};
}
return null;
}, [props.deepLinks]);
return (
@ -133,7 +136,7 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
newVideos={newVideos}
options={options}
optionOnSelect={optionOnSelect}
onPlayClick={props.deepLinks && typeof props.deepLinks.player === 'string' ? onPlayClick : null}
onPlayClick={onPlayClick}
/>
);
};