From d6efbf080a14d3fd6b94f887d1fb250be8e26f9c Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 26 Oct 2021 11:14:02 -0700 Subject: [PATCH] Fix shift-rangeselect on sorted list view --- src/components/library/AlbumList.tsx | 4 +-- src/components/library/AlbumView.tsx | 4 +-- src/components/library/ArtistList.tsx | 4 +-- src/components/library/ArtistView.tsx | 4 +-- src/components/library/FolderList.tsx | 4 +-- src/components/library/GenreList.tsx | 4 +-- src/components/player/NowPlayingMiniView.tsx | 4 +-- src/components/player/NowPlayingView.tsx | 4 +-- src/components/playlist/PlaylistList.tsx | 4 +-- src/components/playlist/PlaylistView.tsx | 8 ++--- src/components/search/SearchView.tsx | 4 +-- .../settings/ConfigPanels/ListViewConfig.tsx | 4 +-- src/components/starred/StarredView.tsx | 4 +-- src/components/viewtypes/ListViewTable.tsx | 36 ++++++++++++------- 14 files changed, 50 insertions(+), 42 deletions(-) diff --git a/src/components/library/AlbumList.tsx b/src/components/library/AlbumList.tsx index 8c0e153..134af80 100644 --- a/src/components/library/AlbumList.tsx +++ b/src/components/library/AlbumList.tsx @@ -90,7 +90,7 @@ const AlbumList = () => { }, [genres]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -99,7 +99,7 @@ const AlbumList = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : albums)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/library/AlbumView.tsx b/src/components/library/AlbumView.tsx index 660ce87..7dd5f80 100644 --- a/src/components/library/AlbumView.tsx +++ b/src/components/library/AlbumView.tsx @@ -64,7 +64,7 @@ const AlbumView = ({ ...rest }: any) => { ]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -73,7 +73,7 @@ const AlbumView = ({ ...rest }: any) => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : data.song)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/library/ArtistList.tsx b/src/components/library/ArtistList.tsx index affc272..6e2d39f 100644 --- a/src/components/library/ArtistList.tsx +++ b/src/components/library/ArtistList.tsx @@ -48,7 +48,7 @@ const ArtistList = () => { const filteredData = useSearchQuery(searchQuery, artists, ['name']); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -57,7 +57,7 @@ const ArtistList = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : artists)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/library/ArtistView.tsx b/src/components/library/ArtistView.tsx index f8dd2d9..a87f59a 100644 --- a/src/components/library/ArtistView.tsx +++ b/src/components/library/ArtistView.tsx @@ -68,7 +68,7 @@ const ArtistView = ({ ...rest }: any) => { ]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -77,7 +77,7 @@ const ArtistView = ({ ...rest }: any) => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : data.album)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/library/FolderList.tsx b/src/components/library/FolderList.tsx index d3e3f41..afc3b47 100644 --- a/src/components/library/FolderList.tsx +++ b/src/components/library/FolderList.tsx @@ -69,7 +69,7 @@ const FolderList = () => { }, [dispatch, query]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -78,7 +78,7 @@ const FolderList = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(folderData.child)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/library/GenreList.tsx b/src/components/library/GenreList.tsx index 9c28ee7..b1c0a0e 100644 --- a/src/components/library/GenreList.tsx +++ b/src/components/library/GenreList.tsx @@ -29,7 +29,7 @@ const GenreList = () => { const filteredData = useSearchQuery(searchQuery, genres, ['value']); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -38,7 +38,7 @@ const GenreList = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : genres)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/player/NowPlayingMiniView.tsx b/src/components/player/NowPlayingMiniView.tsx index bb04b1b..423b838 100644 --- a/src/components/player/NowPlayingMiniView.tsx +++ b/src/components/player/NowPlayingMiniView.tsx @@ -74,7 +74,7 @@ const NowPlayingMiniView = () => { }, [playQueue.currentIndex, tableRef, playQueue.displayQueue, playQueue.scrollWithCurrentSong]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -83,7 +83,7 @@ const NowPlayingMiniView = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(playQueue[getCurrentEntryList(playQueue)])); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/player/NowPlayingView.tsx b/src/components/player/NowPlayingView.tsx index da85a99..3e1560b 100644 --- a/src/components/player/NowPlayingView.tsx +++ b/src/components/player/NowPlayingView.tsx @@ -118,7 +118,7 @@ const NowPlayingView = () => { }, [playQueue.currentIndex, playQueue.scrollWithCurrentSong, tableRef]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -130,7 +130,7 @@ const NowPlayingView = () => { if (searchQuery !== '') { dispatch(toggleRangeSelected(filteredData)); } else { - dispatch(toggleRangeSelected(playQueue[getCurrentEntryList(playQueue)])); + dispatch(toggleRangeSelected(tableData)); } } }, 100); diff --git a/src/components/playlist/PlaylistList.tsx b/src/components/playlist/PlaylistList.tsx index 5e0aa95..d24cde0 100644 --- a/src/components/playlist/PlaylistList.tsx +++ b/src/components/playlist/PlaylistList.tsx @@ -58,7 +58,7 @@ const PlaylistList = () => { }; let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -67,7 +67,7 @@ const PlaylistList = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : playlists)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/playlist/PlaylistView.tsx b/src/components/playlist/PlaylistView.tsx index 7d6aeb3..38e1fcc 100644 --- a/src/components/playlist/PlaylistView.tsx +++ b/src/components/playlist/PlaylistView.tsx @@ -138,7 +138,7 @@ const PlaylistView = ({ ...rest }) => { }, [data?.song, playlist]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -147,11 +147,7 @@ const PlaylistView = ({ ...rest }) => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch( - toggleRangeSelected( - searchQuery !== '' ? filteredData : playlist[getCurrentEntryList(playlist)] - ) - ); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/search/SearchView.tsx b/src/components/search/SearchView.tsx index c1ad04c..b9e7ad2 100644 --- a/src/components/search/SearchView.tsx +++ b/src/components/search/SearchView.tsx @@ -44,7 +44,7 @@ const SearchView = () => { ); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -53,7 +53,7 @@ const SearchView = () => { dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(data.song)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/settings/ConfigPanels/ListViewConfig.tsx b/src/components/settings/ConfigPanels/ListViewConfig.tsx index d52aa19..e595d9b 100644 --- a/src/components/settings/ConfigPanels/ListViewConfig.tsx +++ b/src/components/settings/ConfigPanels/ListViewConfig.tsx @@ -68,7 +68,7 @@ const ListViewConfig = ({ defaultColumns, columnPicker, columnList, settingsConf }, [columnListType, config.lookAndFeel.listView, settingsConfig.columnList]); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -77,7 +77,7 @@ const ListViewConfig = ({ defaultColumns, columnPicker, columnList, settingsConf dispatch(toggleSelected(rowData)); } else if (e.shiftKey) { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(config.lookAndFeel.listView[columnListType].columns)); + dispatch(toggleRangeSelected(tableData)); } }, 100); } diff --git a/src/components/starred/StarredView.tsx b/src/components/starred/StarredView.tsx index eaff06b..9801ae7 100644 --- a/src/components/starred/StarredView.tsx +++ b/src/components/starred/StarredView.tsx @@ -57,7 +57,7 @@ const StarredView = () => { ); let timeout: any = null; - const handleRowClick = (e: any, rowData: any) => { + const handleRowClick = (e: any, rowData: any, tableData: any) => { if (timeout === null) { timeout = window.setTimeout(() => { timeout = null; @@ -74,7 +74,7 @@ const StarredView = () => { } } else if (favorite.active.tab === 'albums') { dispatch(setRangeSelected(rowData)); - dispatch(toggleRangeSelected(searchQuery !== '' ? filteredData : data?.album)); + dispatch(toggleRangeSelected(tableData)); } } }, 100); diff --git a/src/components/viewtypes/ListViewTable.tsx b/src/components/viewtypes/ListViewTable.tsx index 05a5995..5f393f9 100644 --- a/src/components/viewtypes/ListViewTable.tsx +++ b/src/components/viewtypes/ListViewTable.tsx @@ -429,10 +429,14 @@ const ListViewTable = ({ height={rowHeight} onClick={(e: any) => { if (!dnd) { - handleRowClick(e, { - ...rowData, - rowIndex, - }); + handleRowClick( + e, + { + ...rowData, + rowIndex, + }, + sortColumn && !nowPlaying ? sortedData : data + ); } }} onDoubleClick={() => { @@ -529,10 +533,14 @@ const ListViewTable = ({ return ( - handleRowClick(e, { - ...rowData, - rowIndex, - }) + handleRowClick( + e, + { + ...rowData, + rowIndex, + }, + sortColumn && !nowPlaying ? sortedData : data + ) } onDoubleClick={() => handleRowDoubleClick({ @@ -752,10 +760,14 @@ const ListViewTable = ({ /starred|userRating|columnResizable|columnDefaultSort/ ) ) { - handleRowClick(e, { - ...rowData, - rowIndex, - }); + handleRowClick( + e, + { + ...rowData, + rowIndex, + }, + sortColumn && !nowPlaying ? sortedData : data + ); } }} onDoubleClick={() => {