Browse Source

Handle individual page column sorts

master
jeffvli 3 years ago
committed by Jeff
parent
commit
e0f6ddad42
  1. 1
      src/components/library/AlbumList.tsx
  2. 1
      src/components/library/AlbumView.tsx
  3. 1
      src/components/library/ArtistList.tsx
  4. 1
      src/components/library/ArtistView.tsx
  5. 1
      src/components/library/FolderList.tsx
  6. 1
      src/components/library/GenreList.tsx
  7. 1
      src/components/playlist/PlaylistList.tsx
  8. 3
      src/components/starred/StarredView.tsx
  9. 38
      src/components/viewtypes/ListViewTable.tsx
  10. 2
      src/components/viewtypes/ListViewType.tsx

1
src/components/library/AlbumList.tsx

@ -209,6 +209,7 @@ const AlbumList = () => {
cacheType: 'album', cacheType: 'album',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
page="albumListPage"
listType="album" listType="album"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[

1
src/components/library/AlbumView.tsx

@ -356,6 +356,7 @@ const AlbumView = ({ ...rest }: any) => {
cacheType: 'album', cacheType: 'album',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
page="albumPage"
listType="music" listType="music"
isModal={rest.isModal} isModal={rest.isModal}
disabledContextMenuOptions={[ disabledContextMenuOptions={[

1
src/components/library/ArtistList.tsx

@ -138,6 +138,7 @@ const ArtistList = () => {
cacheType: 'artist', cacheType: 'artist',
cacheIdProperty: 'id', cacheIdProperty: 'id',
}} }}
page="artistListPage"
listType="artist" listType="artist"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[

1
src/components/library/ArtistView.tsx

@ -378,6 +378,7 @@ const ArtistView = ({ ...rest }: any) => {
cacheType: 'album', cacheType: 'album',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
page="artistPage"
listType="album" listType="album"
isModal={rest.isModal} isModal={rest.isModal}
disabledContextMenuOptions={[ disabledContextMenuOptions={[

1
src/components/library/FolderList.tsx

@ -227,6 +227,7 @@ const FolderList = () => {
cacheType: 'folder', cacheType: 'folder',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
page="folderListPage"
listType="folder" listType="folder"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[

1
src/components/library/GenreList.tsx

@ -80,6 +80,7 @@ const GenreList = () => {
fontSize={config.lookAndFeel.listView.genre.fontSize} fontSize={config.lookAndFeel.listView.genre.fontSize}
handleRowClick={handleRowClick} handleRowClick={handleRowClick}
handleRowDoubleClick={handleRowDoubleClick} handleRowDoubleClick={handleRowDoubleClick}
page="genreListPage"
listType="genre" listType="genre"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[

1
src/components/playlist/PlaylistList.tsx

@ -161,6 +161,7 @@ const PlaylistList = () => {
cacheType: 'playlist', cacheType: 'playlist',
cacheIdProperty: 'id', cacheIdProperty: 'id',
}} }}
page="playlistListPage"
listType="playlist" listType="playlist"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[

3
src/components/starred/StarredView.tsx

@ -191,6 +191,7 @@ const StarredView = () => {
cacheType: 'album', cacheType: 'album',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
page="favoriteTracksPage"
listType="music" listType="music"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[
@ -217,6 +218,7 @@ const StarredView = () => {
cacheType: 'album', cacheType: 'album',
cacheIdProperty: 'albumId', cacheIdProperty: 'albumId',
}} }}
page="favoriteAlbumsPage"
listType="album" listType="album"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[
@ -264,6 +266,7 @@ const StarredView = () => {
cacheType: 'artist', cacheType: 'artist',
cacheIdProperty: 'id', cacheIdProperty: 'id',
}} }}
page="favoriteArtistsPage"
listType="artist" listType="artist"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[

38
src/components/viewtypes/ListViewTable.tsx

@ -46,7 +46,12 @@ import {
} from '../../redux/multiSelectSlice'; } from '../../redux/multiSelectSlice';
import CustomTooltip from '../shared/CustomTooltip'; import CustomTooltip from '../shared/CustomTooltip';
import { sortPlaylist } from '../../redux/playlistSlice'; import { sortPlaylist } from '../../redux/playlistSlice';
import { removePlaybackFilter, setColumnList, setPlaybackFilter } from '../../redux/configSlice'; import {
removePlaybackFilter,
setColumnList,
setPageSort,
setPlaybackFilter,
} from '../../redux/configSlice';
import { setActive } from '../../redux/albumSlice'; import { setActive } from '../../redux/albumSlice';
import { resetPlayer, setStatus } from '../../redux/playerSlice'; import { resetPlayer, setStatus } from '../../redux/playerSlice';
@ -89,6 +94,7 @@ const ListViewTable = ({
multiSelect, multiSelect,
cacheImages, cacheImages,
autoHeight, autoHeight,
page,
listType, listType,
isModal, isModal,
// onScroll, // onScroll,
@ -139,6 +145,16 @@ const ListViewTable = ({
sortType: type, sortType: type,
}) })
); );
} else if (page) {
dispatch(
setPageSort({
page,
sort: {
sortColumn: column,
sortType: type,
},
})
);
} }
if (column === (nowPlaying ? playQueue.sortColumn : sortColumn)) { if (column === (nowPlaying ? playQueue.sortColumn : sortColumn)) {
@ -152,6 +168,16 @@ const ListViewTable = ({
sortType: 'asc', sortType: 'asc',
}) })
); );
} else if (page) {
dispatch(
setPageSort({
page,
sort: {
sortColumn: undefined,
sortType: 'asc',
},
})
);
} }
setSortColumn(undefined); setSortColumn(undefined);
@ -211,6 +237,14 @@ const ListViewTable = ({
useEffect(() => { useEffect(() => {
if (!nowPlaying) { if (!nowPlaying) {
if (page === 'favoritePage') {
setSortColumn(configState.sort[page.split('.')[0]][page.split('.')[1]]?.sortColumn);
setSortType(configState.sort[page.split('.')[0]][page.split('.')[1]]?.sortType);
} else if (page) {
setSortColumn(configState.sort[page]?.sortColumn);
setSortType(configState.sort[page]?.sortType);
}
if (sortColumn && sortType) { if (sortColumn && sortType) {
// Since the column title(id) won't always match the actual column dataKey, we need to match it // Since the column title(id) won't always match the actual column dataKey, we need to match it
const normalizedSortColumn = columns.find((c: any) => c.id === sortColumn); const normalizedSortColumn = columns.find((c: any) => c.id === sortColumn);
@ -232,7 +266,7 @@ const ListViewTable = ({
setSortedData(data); setSortedData(data);
} }
} }
}, [columns, data, nowPlaying, sortColumn, sortType]); }, [columns, configState.sort, data, nowPlaying, page, sortColumn, sortType]);
useEffect(() => { useEffect(() => {
if (nowPlaying) { if (nowPlaying) {

2
src/components/viewtypes/ListViewType.tsx

@ -25,6 +25,7 @@ const ListViewType = (
fontSize, fontSize,
cacheImages, cacheImages,
children, children,
page,
listType, listType,
isModal, isModal,
handleDragEnd, handleDragEnd,
@ -325,6 +326,7 @@ const ListViewType = (
playQueue={playQueue} playQueue={playQueue}
multiSelect={multiSelect} multiSelect={multiSelect}
cacheImages={cacheImages} cacheImages={cacheImages}
page={page}
listType={listType} listType={listType}
nowPlaying={rest.nowPlaying} nowPlaying={rest.nowPlaying}
playlist={rest.playlist} playlist={rest.playlist}

Loading…
Cancel
Save