From 6cd27669704d04b6662c612bb41abef8d0d23182 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Thu, 10 Mar 2022 20:27:34 -0800 Subject: [PATCH] Change music type play behavior for cards (#236) - Play the song instead of the full album --- src/components/card/Card.tsx | 44 +++++++++++++------ .../scrollingmenu/ScrollingMenu.tsx | 5 ++- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/components/card/Card.tsx b/src/components/card/Card.tsx index 614407e..9b78f9e 100644 --- a/src/components/card/Card.tsx +++ b/src/components/card/Card.tsx @@ -29,7 +29,7 @@ import { addModalPage } from '../../redux/miscSlice'; import CustomTooltip from '../shared/CustomTooltip'; import { CoverArtWrapper, CustomImageGrid, CustomImageGridWrapper } from '../layout/styled'; import usePlayQueueHandler from '../../hooks/usePlayQueueHandler'; -import { Play } from '../../types'; +import { Item, Play } from '../../types'; const Card = ({ onClick, @@ -176,23 +176,35 @@ const Card = ({ size="lg" circle icon={} - onClick={() => - handlePlayQueueAdd({ + onClick={() => { + if (playClick.type === Item.Music) { + return handlePlayQueueAdd({ + byData: [playClick], + play: Play.Play, + }); + } + return handlePlayQueueAdd({ byItemType: { item: playClick.type, id: playClick.id }, play: Play.Play, - }) - } + }); + }} /> - handlePlayQueueAdd({ + onClick={() => { + if (playClick.type === Item.Music) { + return handlePlayQueueAdd({ + byData: [playClick], + play: Play.Later, + }); + } + return handlePlayQueueAdd({ byItemType: { item: playClick.type, id: playClick.id }, play: Play.Later, - }) - } + }); + }} size={size <= 160 ? 'xs' : 'sm'} icon={} /> @@ -201,12 +213,18 @@ const Card = ({ - handlePlayQueueAdd({ + onClick={() => { + if (playClick.type === Item.Music) { + return handlePlayQueueAdd({ + byData: [playClick], + play: Play.Next, + }); + } + return handlePlayQueueAdd({ byItemType: { item: playClick.type, id: playClick.id }, play: Play.Next, - }) - } + }); + }} size={size <= 160 ? 'xs' : 'sm'} icon={} /> diff --git a/src/components/scrollingmenu/ScrollingMenu.tsx b/src/components/scrollingmenu/ScrollingMenu.tsx index 1cbd983..653fb71 100644 --- a/src/components/scrollingmenu/ScrollingMenu.tsx +++ b/src/components/scrollingmenu/ScrollingMenu.tsx @@ -6,6 +6,7 @@ import Card from '../card/Card'; import { SectionTitleWrapper, SectionTitle, StyledButton } from '../shared/styled'; import { useAppSelector } from '../../redux/hooks'; import { smoothScroll } from '../../shared/utils'; +import { Item } from '../../types'; const ScrollMenuContainer = styled.div<{ $noScrollbar?: boolean; maxWidth: string }>` overflow-x: auto; @@ -114,7 +115,7 @@ const ScrollingMenu = ({ coverArt={item.image} url={ cardTitle.urlProperty - ? `${cardTitle.prefix}/${type === 'music' ? item.albumId : item.id}` + ? `${cardTitle.prefix}/${type === Item.Music ? item.albumId : item.id}` : undefined } subUrl={ @@ -122,7 +123,7 @@ const ScrollingMenu = ({ ? `${cardSubtitle.prefix}/${item[cardSubtitle.urlProperty]}` : undefined } - playClick={{ type, id: type === 'music' ? item.albumId : item.id }} + playClick={type === Item.Music ? item : { type, id: item.id }} details={{ cacheType: type, ...item }} hasHoverButtons size={cardSize || config.lookAndFeel.gridView.cardSize}