From 68c0a4fb1382156e367e5ca1d0303fee191129a2 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 2 Mar 2026 13:38:45 +0200 Subject: [PATCH] refactor: simplify handling on the libitem --- src/components/LibItem/LibItem.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/LibItem/LibItem.js b/src/components/LibItem/LibItem.js index 7157d913a..28769ddcf 100644 --- a/src/components/LibItem/LibItem.js +++ b/src/components/LibItem/LibItem.js @@ -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} /> ); };