From 0547b1675e8563ed88a2c197b4964c3f4cb4108b Mon Sep 17 00:00:00 2001 From: kKaskak <117831817+kKaskak@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:56:38 +0200 Subject: [PATCH] refactor: chain the elements that are returned --- src/common/LibItem/LibItem.js | 39 ++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/common/LibItem/LibItem.js b/src/common/LibItem/LibItem.js index 9753dc816..88717c64c 100644 --- a/src/common/LibItem/LibItem.js +++ b/src/common/LibItem/LibItem.js @@ -16,32 +16,29 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => { }, [_id, notifications]); const options = React.useMemo(() => { - const optionsList = [ + return [ { label: 'LIBRARY_PLAY', value: 'play' }, { label: 'LIBRARY_DETAILS', value: 'details' }, { label: 'LIBRARY_RESUME_DISMISS', value: 'dismiss' }, { label: watched ? 'CTX_MARK_UNWATCHED' : 'CTX_MARK_WATCHED', value: 'watched' }, { label: 'LIBRARY_REMOVE', value: 'remove' }, - ]; - return optionsList - .filter(({ value }) => { - switch (value) { - case 'play': - return props.deepLinks && typeof props.deepLinks.player === 'string'; - case 'details': - return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string'); - case 'watched': - return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string'); - case 'dismiss': - return typeof _id === 'string' && props.progress !== null && !isNaN(props.progress); - case 'remove': - return typeof _id === 'string' && removable; - } - }) - .map((option) => ({ - ...option, - label: t(option.label) - })); + ].filter(({ value }) => { + switch (value) { + case 'play': + return props.deepLinks && typeof props.deepLinks.player === 'string'; + case 'details': + return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string'); + case 'watched': + return props.deepLinks && (typeof props.deepLinks.metaDetailsVideos === 'string' || typeof props.deepLinks.metaDetailsStreams === 'string'); + case 'dismiss': + return typeof _id === 'string' && props.progress !== null && !isNaN(props.progress); + case 'remove': + return typeof _id === 'string' && removable; + } + }).map((option) => ({ + ...option, + label: t(option.label) + })); }, [_id, removable, props.progress, props.deepLinks]); const optionOnSelect = React.useCallback((event) => {