From c9e1464bbf02b4b57735a66a283c1e95c8cb5615 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sat, 9 Oct 2021 11:49:32 -0700 Subject: [PATCH] Add 'play next' to context menu --- src/components/shared/ContextMenu.tsx | 23 +++++++++++++--------- src/components/viewtypes/ListViewTable.tsx | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/shared/ContextMenu.tsx b/src/components/shared/ContextMenu.tsx index 64256c9..cbcc646 100644 --- a/src/components/shared/ContextMenu.tsx +++ b/src/components/shared/ContextMenu.tsx @@ -153,13 +153,13 @@ export const GlobalContextMenu = () => { } }; - const handleAddToQueue = async () => { + const handleAddToQueue = async (type: 'next' | 'later') => { dispatch(setContextMenu({ show: false })); const promises = []; if (misc.contextMenu.type === 'music' || misc.contextMenu.type === 'nowPlaying') { const entriesByRowIndexAsc = _.orderBy(multiSelect.selected, 'rowIndex', 'asc'); - dispatch(appendPlayQueue({ entries: entriesByRowIndexAsc })); + dispatch(appendPlayQueue({ entries: entriesByRowIndexAsc, type })); notifyToast('info', `Added ${multiSelect.selected.length} song(s)`); } else if (misc.contextMenu.type === 'playlist') { for (let i = 0; i < multiSelect.selected.length; i += 1) { @@ -168,7 +168,7 @@ export const GlobalContextMenu = () => { const res = await Promise.all(promises); const songs = _.flatten(_.map(res, 'song')); - dispatch(appendPlayQueue({ entries: songs })); + dispatch(appendPlayQueue({ entries: songs, type })); notifyToast('info', `Added ${songs.length} song(s)`); } else if (misc.contextMenu.type === 'album') { for (let i = 0; i < multiSelect.selected.length; i += 1) { @@ -177,7 +177,7 @@ export const GlobalContextMenu = () => { const res = await Promise.all(promises); const songs = _.flatten(_.map(res, 'song')); - dispatch(appendPlayQueue({ entries: songs })); + dispatch(appendPlayQueue({ entries: songs, type })); notifyToast('info', `Added ${songs.length} song(s)`); } else if (misc.contextMenu.type === 'artist') { for (let i = 0; i < multiSelect.selected.length; i += 1) { @@ -186,7 +186,7 @@ export const GlobalContextMenu = () => { const res = await Promise.all(promises); const songs = _.flatten(res); - dispatch(appendPlayQueue({ entries: songs })); + dispatch(appendPlayQueue({ entries: songs, type })); notifyToast('info', `Added ${songs.length} song(s)`); } @@ -462,7 +462,7 @@ export const GlobalContextMenu = () => { xPos={misc.contextMenu.xPos} yPos={misc.contextMenu.yPos} width={190} - numOfButtons={8} + numOfButtons={9} numOfDividers={3} > { disabled={misc.contextMenu.disabledOptions.includes('play')} /> handleAddToQueue('next')} + disabled={misc.contextMenu.disabledOptions.includes('addToQueueNext')} + /> + handleAddToQueue('later')} + disabled={misc.contextMenu.disabledOptions.includes('addToQueueLast')} /> = window.innerHeight) { pageY = e.pageY - contextMenuHeight; } else {