Support genres in context menu

This commit is contained in:
jeffvli 2023-08-04 02:27:04 -07:00
parent 0b207c78e7
commit d0aba6e16e
12 changed files with 182 additions and 56 deletions

View file

@ -52,6 +52,13 @@ export const ALBUM_CONTEXT_MENU_ITEMS: SetContextMenuItems = [
{ children: true, disabled: false, id: 'setRating' },
];
export const GENRE_CONTEXT_MENU_ITEMS: SetContextMenuItems = [
{ id: 'play' },
{ id: 'playLast' },
{ divider: true, id: 'playNext' },
{ divider: true, id: 'addToPlaylist' },
];
export const ARTIST_CONTEXT_MENU_ITEMS: SetContextMenuItems = [
{ id: 'play' },
{ id: 'playLast' },

View file

@ -196,6 +196,12 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
playType,
});
break;
case LibraryItem.GENRE:
handlePlayQueueAdd?.({
byItemType: { id: ctx.data.map((item) => item.id), type: ctx.type },
playType,
});
break;
case LibraryItem.SONG:
handlePlayQueueAdd?.({ byData: ctx.data, playType });
break;
@ -403,9 +409,11 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
const albumId: string[] = [];
const artistId: string[] = [];
const songId: string[] = [];
const genreId: string[] = [];
if (ctx.dataNodes) {
for (const node of ctx.dataNodes) {
console.log('node.data.itemType :>> ', node.data.itemType);
switch (node.data.itemType) {
case LibraryItem.ALBUM:
albumId.push(node.data.id);
@ -413,6 +421,9 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
case LibraryItem.ARTIST:
artistId.push(node.data.id);
break;
case LibraryItem.GENRE:
genreId.push(node.data.id);
break;
case LibraryItem.SONG:
songId.push(node.data.id);
break;
@ -427,6 +438,9 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
case LibraryItem.ARTIST:
artistId.push(item.id);
break;
case LibraryItem.GENRE:
genreId.push(item.id);
break;
case LibraryItem.SONG:
songId.push(item.id);
break;
@ -434,10 +448,13 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
}
}
console.log('genreId', genreId);
openContextModal({
innerProps: {
albumId: albumId.length > 0 ? albumId : undefined,
artistId: artistId.length > 0 ? artistId : undefined,
genreId: genreId.length > 0 ? genreId : undefined,
songId: songId.length > 0 ? songId : undefined,
},
modal: 'addToPlaylist',