From a75cac291a875361e171c2818acbb5f0def73deb Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Wed, 1 Jul 2026 16:45:36 -0400 Subject: [PATCH 1/4] make sortby an array --- .../libraries/components/ItemsView.tsx | 4 +- .../libraries/components/SortButton.tsx | 200 +++++++++--------- .../features/libraries/utils/settings.ts | 6 +- src/hooks/useFetchItems.ts | 10 +- src/types/library.ts | 2 +- 5 files changed, 110 insertions(+), 112 deletions(-) diff --git a/src/apps/modern/features/libraries/components/ItemsView.tsx b/src/apps/modern/features/libraries/components/ItemsView.tsx index 5f3f5f8979..613feda79c 100644 --- a/src/apps/modern/features/libraries/components/ItemsView.tsx +++ b/src/apps/modern/features/libraries/components/ItemsView.tsx @@ -57,7 +57,7 @@ const ItemsView: FC = () => { listOptions.showArtist = true; listOptions.addToListButton = true; } else if (viewType === LibraryTab.Albums) { - listOptions.sortBy = libraryViewSettings.SortBy; + listOptions.sortBy = libraryViewSettings.SortBy[0]; listOptions.addToListButton = true; } else if (viewType === LibraryTab.Episodes) { listOptions.showParentTitle = true; @@ -171,7 +171,7 @@ const ItemsView: FC = () => { noItemsMessage ]); - const hasSortName = libraryViewSettings.SortBy !== ItemSortBy.Random; + const hasSortName = libraryViewSettings.SortBy[0] !== ItemSortBy.Random; const itemsContainerClass = classNames( 'padded-left padded-right', diff --git a/src/apps/modern/features/libraries/components/SortButton.tsx b/src/apps/modern/features/libraries/components/SortButton.tsx index 5b99aee1e6..31f6224a55 100644 --- a/src/apps/modern/features/libraries/components/SortButton.tsx +++ b/src/apps/modern/features/libraries/components/SortButton.tsx @@ -17,49 +17,49 @@ import { LibraryTab } from 'types/libraryTab'; type SortOption = { label: string; - value: ItemSortBy; + value: ItemSortBy[]; }; type SortOptionsMapping = Record; const collectionMovieOptions: SortOption[] = [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] } ]; const movieOrFavoriteOptions = [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionCriticRating', value: ItemSortBy.CriticRating }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionPlayCount', value: ItemSortBy.PlayCount }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionCriticRating', value: [ItemSortBy.CriticRating, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ]; const photosOrPhotoAlbumsOptions = [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] } ]; const videoOrMusicVideoOptions = [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionPlayCount', value: ItemSortBy.PlayCount }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ]; const sortOptionsMapping: SortOptionsMapping = { @@ -67,91 +67,91 @@ const sortOptionsMapping: SortOptionsMapping = { [LibraryTab.Collections]: collectionMovieOptions, [LibraryTab.Favorites]: movieOrFavoriteOptions, [LibraryTab.Series]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionDateShowAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDateEpisodeAdded', value: ItemSortBy.DateLastContentAdded }, - { label: 'OptionDatePlayed', value: ItemSortBy.SeriesDatePlayed }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionDateShowAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDateEpisodeAdded', value: [ItemSortBy.DateLastContentAdded, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.SeriesDatePlayed, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] } ], [LibraryTab.Episodes]: [ - { label: 'Name', value: ItemSortBy.SeriesSortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionPlayCount', value: ItemSortBy.PlayCount }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SeriesSortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ], [LibraryTab.Albums]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'AlbumArtist', value: ItemSortBy.AlbumArtist }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionCriticRating', value: ItemSortBy.CriticRating }, - { label: 'OptionReleaseDate', value: ItemSortBy.ProductionYear }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'AlbumArtist', value: [ItemSortBy.AlbumArtist, ItemSortBy.SortName] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionCriticRating', value: [ItemSortBy.CriticRating, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] } ], [LibraryTab.Books]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionReleaseDate', value: ItemSortBy.ProductionYear }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'IndexNumber', value: ItemSortBy.IndexNumber } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'IndexNumber', value: [ItemSortBy.IndexNumber, ItemSortBy.SortName] } ], [LibraryTab.Songs]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'Album', value: ItemSortBy.Album }, - { label: 'AlbumArtist', value: ItemSortBy.AlbumArtist }, - { label: 'Artist', value: ItemSortBy.Artist }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'OptionPlayCount', value: ItemSortBy.PlayCount }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'Album', value: [ItemSortBy.Album, ItemSortBy.SortName] }, + { label: 'AlbumArtist', value: [ItemSortBy.AlbumArtist, ItemSortBy.SortName] }, + { label: 'Artist', value: [ItemSortBy.Artist, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ], [LibraryTab.Playlists]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDatePlaylistUpdated', value: ItemSortBy.DateLastContentAdded }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDatePlaylistUpdated', value: [ItemSortBy.DateLastContentAdded, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ], [LibraryTab.PhotoAlbums]: photosOrPhotoAlbumsOptions, [LibraryTab.Photos]: photosOrPhotoAlbumsOptions, [LibraryTab.Videos]:videoOrMusicVideoOptions, [LibraryTab.MusicVideos]:videoOrMusicVideoOptions, [LibraryTab.Folders]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'Folders', value: ItemSortBy.IsFolder }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionPlayCount', value: ItemSortBy.PlayCount }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'Folders', value: [ItemSortBy.IsFolder, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ], [LibraryTab.Mixed]: [ - { label: 'Name', value: ItemSortBy.SortName }, - { label: 'OptionRandom', value: ItemSortBy.Random }, - { label: 'OptionCommunityRating', value: ItemSortBy.CommunityRating }, - { label: 'OptionCriticRating', value: ItemSortBy.CriticRating }, - { label: 'OptionDateAdded', value: ItemSortBy.DateCreated }, - { label: 'OptionDateEpisodeAdded', value: ItemSortBy.DateLastContentAdded }, - { label: 'OptionDatePlayed', value: ItemSortBy.DatePlayed }, - { label: 'OptionParentalRating', value: ItemSortBy.OfficialRating }, - { label: 'OptionPlayCount', value: ItemSortBy.PlayCount }, - { label: 'OptionReleaseDate', value: ItemSortBy.PremiereDate }, - { label: 'Runtime', value: ItemSortBy.Runtime } + { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionRandom', value: [ItemSortBy.Random] }, + { label: 'OptionCommunityRating', value: [ItemSortBy.CommunityRating, ItemSortBy.SortName] }, + { label: 'OptionCriticRating', value: [ItemSortBy.CriticRating, ItemSortBy.SortName] }, + { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, + { label: 'OptionDateEpisodeAdded', value: [ItemSortBy.DateLastContentAdded, ItemSortBy.SortName] }, + { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, + { label: 'OptionParentalRating', value: [ItemSortBy.OfficialRating, ItemSortBy.SortName] }, + { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } ] }; @@ -186,11 +186,11 @@ const SortButton: FC = ({ }, []); const onMenuItemClick = useCallback( - (sortBy: ItemSortBy) => { + (sortBy: ItemSortBy[]) => { setLibraryViewSettings((prevState) => { let sortOrder: SortOrder = SortOrder.Ascending; // If the user clicks the currently selected sort option, toggle the sort order - if (prevState.SortBy === sortBy) { + if (prevState.SortBy[0] === sortBy[0]) { sortOrder = prevState.SortOrder === SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending; } @@ -235,7 +235,7 @@ const SortButton: FC = ({ {sortMenuOptions .map((option) => ( onMenuItemClick(option.value)} > @@ -243,7 +243,7 @@ const SortButton: FC = ({ {globalize.translate(option.label)} - {libraryViewSettings.SortBy === option.value && ( + {libraryViewSettings.SortBy[0] === option.value[0] && ( libraryViewSettings.SortOrder === SortOrder.Ascending ? ( ) : ( diff --git a/src/apps/modern/features/libraries/utils/settings.ts b/src/apps/modern/features/libraries/utils/settings.ts index 79eae16e3e..d379b8fcb7 100644 --- a/src/apps/modern/features/libraries/utils/settings.ts +++ b/src/apps/modern/features/libraries/utils/settings.ts @@ -6,12 +6,12 @@ import { SortOrder } from '@jellyfin/sdk/lib/generated-client/models/sort-order' import { type ParentId, ViewMode, type LibraryViewSettings } from 'types/library'; import { LibraryTab } from 'types/libraryTab'; -export const getDefaultSortBy = (viewType: LibraryTab) => { +export const getDefaultSortBy = (viewType: LibraryTab): ItemSortBy[] => { if (viewType === LibraryTab.Episodes) { - return ItemSortBy.SeriesSortName; + return [ItemSortBy.SeriesSortName]; } - return ItemSortBy.SortName; + return [ItemSortBy.SortName]; }; export const getDefaultLibraryViewSettings = (viewType: LibraryTab): LibraryViewSettings => { diff --git a/src/hooks/useFetchItems.ts b/src/hooks/useFetchItems.ts index 38dd298cb3..b242527872 100644 --- a/src/hooks/useFetchItems.ts +++ b/src/hooks/useFetchItems.ts @@ -245,7 +245,7 @@ const fetchGetItemsViewByType = async ( ...getFiltersQuery(viewType, libraryViewSettings), ...getLimitQuery(), ...getAlphaPickerQuery(libraryViewSettings), - sortBy: [libraryViewSettings.SortBy], + sortBy: libraryViewSettings.SortBy, sortOrder: [libraryViewSettings.SortOrder], includeItemTypes: itemType, startIndex: libraryViewSettings.StartIndex @@ -266,7 +266,7 @@ const fetchGetItemsViewByType = async ( ...getFiltersQuery(viewType, libraryViewSettings), ...getLimitQuery(), ...getAlphaPickerQuery(libraryViewSettings), - sortBy: [libraryViewSettings.SortBy], + sortBy: libraryViewSettings.SortBy, sortOrder: [libraryViewSettings.SortOrder], includeItemTypes: itemType, startIndex: libraryViewSettings.StartIndex @@ -341,9 +341,7 @@ const fetchGetItemsViewByType = async ( ...getFiltersQuery(viewType, libraryViewSettings), ...getLimitQuery(), ...getAlphaPickerQuery(libraryViewSettings), - sortBy: libraryViewSettings.SortBy === ItemSortBy.IsFolder ? - [ItemSortBy.IsFolder, ItemSortBy.SortName] : - [libraryViewSettings.SortBy], + sortBy: libraryViewSettings.SortBy, sortOrder: [libraryViewSettings.SortOrder], includeItemTypes: itemType, startIndex: libraryViewSettings.StartIndex @@ -378,7 +376,7 @@ const fetchGetItemsViewByType = async ( ...getLimitQuery(), ...getAlphaPickerQuery(libraryViewSettings), isFavorite: viewType === LibraryTab.Favorites ? true : undefined, - sortBy: [libraryViewSettings.SortBy], + sortBy: libraryViewSettings.SortBy, sortOrder: [libraryViewSettings.SortOrder], includeItemTypes: itemType, startIndex: libraryViewSettings.StartIndex diff --git a/src/types/library.ts b/src/types/library.ts index 8715151c77..cfd1f79d5a 100644 --- a/src/types/library.ts +++ b/src/types/library.ts @@ -53,7 +53,7 @@ export enum ViewMode { } export interface LibraryViewSettings { - SortBy: ItemSortBy; + SortBy: ItemSortBy[]; SortOrder: SortOrder; StartIndex: number; CardLayout: boolean; From 3ac27ec5a631fed50aadbaf1dff5bcbc0d11267a Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Tue, 21 Jul 2026 17:49:26 -0400 Subject: [PATCH 2/4] Apply review feedback --- .../modern/features/libraries/components/PlayAllButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/modern/features/libraries/components/PlayAllButton.tsx b/src/apps/modern/features/libraries/components/PlayAllButton.tsx index 8b24a665e4..19a1f43245 100644 --- a/src/apps/modern/features/libraries/components/PlayAllButton.tsx +++ b/src/apps/modern/features/libraries/components/PlayAllButton.tsx @@ -43,7 +43,7 @@ const PlayAllButton: FC = ({ items: [item], autoplay: true, queryOptions: { - SortBy: [libraryViewSettings.SortBy], + SortBy: libraryViewSettings.SortBy, SortOrder: [libraryViewSettings.SortOrder] } }).catch(err => { @@ -56,7 +56,7 @@ const PlayAllButton: FC = ({ queryOptions: { ParentId: item?.Id ?? undefined, ...getFiltersQuery(viewType, libraryViewSettings), - SortBy: [libraryViewSettings.SortBy], + SortBy: libraryViewSettings.SortBy, SortOrder: [libraryViewSettings.SortOrder] } }).catch(err => { From 675556c53febb34b78d2fe5b6f446d896f899f5f Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Fri, 31 Jul 2026 11:09:30 -0400 Subject: [PATCH 3/4] Apply review feedback --- src/apps/modern/features/libraries/components/ItemsView.tsx | 2 +- src/apps/modern/features/libraries/components/SortButton.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apps/modern/features/libraries/components/ItemsView.tsx b/src/apps/modern/features/libraries/components/ItemsView.tsx index 613feda79c..629fb6281d 100644 --- a/src/apps/modern/features/libraries/components/ItemsView.tsx +++ b/src/apps/modern/features/libraries/components/ItemsView.tsx @@ -171,7 +171,7 @@ const ItemsView: FC = () => { noItemsMessage ]); - const hasSortName = libraryViewSettings.SortBy[0] !== ItemSortBy.Random; + const hasSortName = !libraryViewSettings.SortBy.includes(ItemSortBy.Random); const itemsContainerClass = classNames( 'padded-left padded-right', diff --git a/src/apps/modern/features/libraries/components/SortButton.tsx b/src/apps/modern/features/libraries/components/SortButton.tsx index 31f6224a55..e73a4df736 100644 --- a/src/apps/modern/features/libraries/components/SortButton.tsx +++ b/src/apps/modern/features/libraries/components/SortButton.tsx @@ -14,6 +14,7 @@ import Popover from '@mui/material/Popover'; import globalize from 'lib/globalize'; import { LibraryViewSettings } from 'types/library'; import { LibraryTab } from 'types/libraryTab'; +import isEqual from 'lodash-es/isEqual'; type SortOption = { label: string; @@ -190,7 +191,7 @@ const SortButton: FC = ({ setLibraryViewSettings((prevState) => { let sortOrder: SortOrder = SortOrder.Ascending; // If the user clicks the currently selected sort option, toggle the sort order - if (prevState.SortBy[0] === sortBy[0]) { + if (isEqual(prevState.SortBy, sortBy)) { sortOrder = prevState.SortOrder === SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending; } @@ -243,7 +244,7 @@ const SortButton: FC = ({ {globalize.translate(option.label)} - {libraryViewSettings.SortBy[0] === option.value[0] && ( + {isEqual(libraryViewSettings.SortBy, option.value) && ( libraryViewSettings.SortOrder === SortOrder.Ascending ? ( ) : ( From 8d897123c9dac2ff0853e7ad609b869c2fbeedd5 Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Fri, 31 Jul 2026 11:12:06 -0400 Subject: [PATCH 4/4] Fix songs tab sorting --- .../features/libraries/components/SortButton.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/apps/modern/features/libraries/components/SortButton.tsx b/src/apps/modern/features/libraries/components/SortButton.tsx index e73a4df736..a53bf3e01f 100644 --- a/src/apps/modern/features/libraries/components/SortButton.tsx +++ b/src/apps/modern/features/libraries/components/SortButton.tsx @@ -106,16 +106,16 @@ const sortOptionsMapping: SortOptionsMapping = { { label: 'IndexNumber', value: [ItemSortBy.IndexNumber, ItemSortBy.SortName] } ], [LibraryTab.Songs]: [ - { label: 'Name', value: [ItemSortBy.SortName] }, + { label: 'OptionTrackName', value: [ItemSortBy.Name] }, { label: 'OptionRandom', value: [ItemSortBy.Random] }, - { label: 'Album', value: [ItemSortBy.Album, ItemSortBy.SortName] }, - { label: 'AlbumArtist', value: [ItemSortBy.AlbumArtist, ItemSortBy.SortName] }, - { label: 'Artist', value: [ItemSortBy.Artist, ItemSortBy.SortName] }, + { label: 'Album', value: [ItemSortBy.Album, ItemSortBy.AlbumArtist, ItemSortBy.SortName] }, + { label: 'AlbumArtist', value: [ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName] }, + { label: 'Artist', value: [ItemSortBy.Artist, ItemSortBy.Album, ItemSortBy.SortName] }, { label: 'OptionDateAdded', value: [ItemSortBy.DateCreated, ItemSortBy.SortName] }, { label: 'OptionDatePlayed', value: [ItemSortBy.DatePlayed, ItemSortBy.SortName] }, { label: 'OptionPlayCount', value: [ItemSortBy.PlayCount, ItemSortBy.SortName] }, - { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName] }, - { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.SortName] } + { label: 'OptionReleaseDate', value: [ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName] }, + { label: 'Runtime', value: [ItemSortBy.Runtime, ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName] } ], [LibraryTab.Playlists]: [ { label: 'Name', value: [ItemSortBy.SortName] },