From b805d7eeb3dc2c700dfe36f4897d14e669b2f994 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 29 Jan 2024 16:53:08 +0300 Subject: [PATCH] media-item-fix --- src/components/Article/AudioPlayer/PlayerPlaylist.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx index 07cee3bd..b4eec25f 100644 --- a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx +++ b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx @@ -25,6 +25,8 @@ type Props = { onChangeMediaIndex?: (direction: 'up' | 'down', index) => void } +const getMediaTitle = (itm: MediaItem, idx: number) => `${idx}. ${itm.artist} - ${itm.title}` + export const PlayerPlaylist = (props: Props) => { const { t } = useLocalize() const [activeEditIndex, setActiveEditIndex] = createSignal(-1) @@ -36,11 +38,12 @@ export const PlayerPlaylist = (props: Props) => { props.onMediaItemFieldChange(activeEditIndex(), field, value) } - const play = (index) => { + const play = (index: number) => { const mi = props.media[index] gtag('event', 'select_item', { item_list_id: props.articleSlug, - item_list_name: mi.title || '' + ' - ' + mi.artist || '', + item_list_name: getMediaTitle(mi, index), + items: props.media.map((it, ix) => getMediaTitle(it, ix)), }) } return (