Skip to content

Commit

Permalink
Set row play button to switch to song on queue lists
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffvli committed Oct 10, 2024
1 parent a00385e commit a8b3944
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ const ListConverControlsContainer = styled.div`
export const ListCoverControls = ({
itemData,
itemType,
context,
uniqueId,
}: {
context: Record<string, any>;
itemData: any;
itemType: LibraryItem;
uniqueId?: string;
}) => {
const playButtonBehavior = usePlayButtonBehavior();
const handlePlayQueueAdd = usePlayQueueAdd();
const isQueue = Boolean(context?.isQueue);

const handlePlay = async (e: MouseEvent<HTMLButtonElement>, playType?: Play) => {
e.preventDefault();
Expand All @@ -72,10 +77,18 @@ export const ListCoverControls = ({
});
};

const handlePlayFromQueue = () => {
context.handleDoubleClick({
data: {
uniqueId,
},
});
};

return (
<>
<ListConverControlsContainer className="card-controls">
<PlayButton onClick={handlePlay}>
<PlayButton onClick={isQueue ? handlePlayFromQueue : handlePlay}>
<RiPlayFill size={20} />
</PlayButton>
</ListConverControlsContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ const StyledImage = styled(SimpleImg)`
}
`;

export const CombinedTitleCell = ({ value, rowIndex, node, context }: ICellRendererParams) => {
export const CombinedTitleCell = ({
value,
rowIndex,
node,
context,
data,
}: ICellRendererParams) => {
const artists = useMemo(() => {
if (!value) return null;
return value.artists?.length ? value.artists : value.albumArtists;
Expand Down Expand Up @@ -114,8 +120,10 @@ export const CombinedTitleCell = ({ value, rowIndex, node, context }: ICellRende
</Center>
)}
<ListCoverControls
context={context}
itemData={value}
itemType={context.itemType}
uniqueId={data?.uniqueId}
/>
</ImageWrapper>
<MetadataWrapper>
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/features/now-playing/components/play-queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
columnDefs={columnDefs}
context={{
currentSong,
handleDoubleClick,
isFocused,
isQueue: true,
itemType: LibraryItem.SONG,
onCellContextMenu,
status,
Expand Down

0 comments on commit a8b3944

Please sign in to comment.