Set row play button to switch to song on queue lists

This commit is contained in:
jeffvli 2024-10-09 18:20:04 -07:00
parent a00385e78f
commit a8b3944c66
3 changed files with 25 additions and 2 deletions

View File

@ -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();
@ -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>

View File

@ -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;
@ -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>

View File

@ -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,