From c43ba347c49ac77d0e72fc9a3ff49c49e7bc8ced Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sat, 25 Sep 2021 02:07:14 -0700 Subject: [PATCH] Starred/NowPlaying view cleanup - Add functionality to miniview buttons --- src/components/player/NowPlayingMiniView.tsx | 57 ++++++------ src/components/player/NowPlayingView.tsx | 72 +++++--------- src/components/starred/StarredView.tsx | 98 ++++++++++---------- 3 files changed, 101 insertions(+), 126 deletions(-) diff --git a/src/components/player/NowPlayingMiniView.tsx b/src/components/player/NowPlayingMiniView.tsx index 1caf54e..2fe7c9d 100644 --- a/src/components/player/NowPlayingMiniView.tsx +++ b/src/components/player/NowPlayingMiniView.tsx @@ -26,12 +26,7 @@ import ListViewType from '../viewtypes/ListViewType'; import GenericPage from '../layout/GenericPage'; import { StyledCheckbox, StyledIconButton } from '../shared/styled'; import { MiniViewContainer } from './styled'; -import { - DeselectAllButton, - MoveDownButton, - MoveManualButton, - MoveUpButton, -} from '../selectionbar/SelectionButtons'; +import { DeselectAllButton, MoveDownButton, MoveUpButton } from '../selectionbar/SelectionButtons'; import { getCurrentEntryList } from '../../shared/utils'; const NowPlayingMiniView = () => { @@ -85,23 +80,11 @@ const NowPlayingMiniView = () => { }; const handleUpClick = () => { - const selectedIndexes: any[] = []; - multiSelect.selected.map((selected: any) => { - return selectedIndexes.push( - playQueue.entry.findIndex((item: any) => item.id === selected.id) - ); - }); - dispatch(moveUp(selectedIndexes)); + dispatch(moveUp({ selectedEntries: multiSelect.selected })); }; const handleDownClick = () => { - const selectedIndexes: any[] = []; - multiSelect.selected.map((selected: any) => { - return selectedIndexes.push( - playQueue.entry.findIndex((item: any) => item.id === selected.id) - ); - }); - dispatch(moveDown(selectedIndexes)); + dispatch(moveDown({ selectedEntries: multiSelect.selected })); }; const handleDragEnd = () => { @@ -156,18 +139,32 @@ const NowPlayingMiniView = () => { } }} /> + {multiSelect.selected.length > 0 && ( + <> + { + dispatch(moveUp({ selectedEntries: multiSelect.selected })); + + if (playQueue.currentPlayer === 1) { + dispatch(fixPlayer2Index()); + } + }} + /> + { + dispatch(moveDown({ selectedEntries: multiSelect.selected })); + + if (playQueue.currentPlayer === 1) { + dispatch(fixPlayer2Index()); + } + }} + /> + + + )} - {multiSelect.selected.length > 0 && ( - - - - - - - - - )} + { dispatch(setStatus('PLAYING')); }; - const handleUpClick = () => { - const selectedIndexes: any[] = []; - multiSelect.selected.map((selected: any) => { - return selectedIndexes.push( - playQueue.entry.findIndex((item: any) => item.id === selected.id) - ); - }); - dispatch(moveUp(selectedIndexes)); - }; - - const handleDownClick = () => { - const selectedIndexes: any[] = []; - multiSelect.selected.map((selected: any) => { - return selectedIndexes.push( - playQueue.entry.findIndex((item: any) => item.id === selected.id) - ); - }); - dispatch(moveDown(selectedIndexes)); - }; - const handleDragEnd = () => { if (multiSelect.isDragging) { dispatch( @@ -123,10 +101,6 @@ const NowPlayingView = () => { } }; - if (!playQueue) { - return ; - } - return ( { /> } > - + {!playQueue ? ( + + ) : ( + + )} ); }; diff --git a/src/components/starred/StarredView.tsx b/src/components/starred/StarredView.tsx index 3a93613..2153a7f 100644 --- a/src/components/starred/StarredView.tsx +++ b/src/components/starred/StarredView.tsx @@ -82,10 +82,6 @@ const StarredView = () => { history.push(`/library/album/${e.id}`); }; - if (isLoading) { - return ; - } - if (isError) { return Error: {error.message}; } @@ -114,62 +110,68 @@ const StarredView = () => { /> } > - {currentPage === 'Tracks' && ( - - )} - {currentPage === 'Albums' && ( + {isLoading ? ( + + ) : ( <> - {viewType === 'list' && ( + {currentPage === 'Tracks' && ( )} - {viewType === 'grid' && ( - + {currentPage === 'Albums' && ( + <> + {viewType === 'list' && ( + + )} + {viewType === 'grid' && ( + + )} + )} )}