add SortName client side sort option (#1612)

This commit is contained in:
jeffvli
2026-01-28 20:45:47 -08:00
parent 78aebd7c5d
commit ced3b491ff
10 changed files with 54 additions and 18 deletions
@@ -241,6 +241,7 @@ const normalizeSong = (
releaseYear: item.ProductionYear || null,
sampleRate,
size,
sortName: item.SortName || item.Name,
tags: getTags(item),
trackNumber: item.IndexNumber,
trackSubtitle: null,
@@ -313,6 +314,7 @@ const normalizeAlbum = (
size: null,
songCount: item?.ChildCount || null,
songs: item.Songs?.map((song) => normalizeSong(song, server)),
sortName: item.SortName || item.Name,
tags: getTags(item),
updatedAt: item?.DateLastMediaAdded || item.DateCreated,
userFavorite: item.UserData?.IsFavorite || false,
@@ -560,6 +560,7 @@ const album = z.object({
RunTimeTicks: z.number(),
ServerId: z.string(),
Songs: z.array(song).optional(), // This is not a native Jellyfin property -- this is used for combined album detail
SortName: z.string().optional(),
Studios: z.array(studio),
Tags: z.string().array().optional(),
Type: z.string(),
@@ -299,6 +299,7 @@ const normalizeSong = (
releaseYear: item.year || null,
sampleRate: item.sampleRate || null,
size: item.size,
sortName: item.orderTitle,
tags: item.tags || null,
trackNumber: item.trackNumber,
trackSubtitle: item.tags?.subtitle ? item.tags.subtitle.join(' · ') : null,
@@ -405,6 +406,7 @@ const normalizeAlbum = (
songs: item.songs
? item.songs.map((song) => normalizeSong(song, server, pathReplace, pathReplaceWith))
: undefined,
sortName: item.orderAlbumName,
tags: item.tags || null,
updatedAt: item.updatedAt,
userFavorite: item.starred || false,
@@ -196,6 +196,7 @@ const normalizeSong = (
releaseYear: item.year || null,
sampleRate: item.samplingRate || null,
size: item.size,
sortName: item.title,
tags: null,
trackNumber: item.track || 1,
trackSubtitle: null,
@@ -321,6 +322,7 @@ const normalizeAlbum = (
(item as z.infer<typeof ssType._response.album>).song?.map((song) =>
normalizeSong(song, server, pathReplace, pathReplaceWith, undefined, discTitleMap),
) || [],
sortName: item.title,
tags: null,
updatedAt: item.created,
userFavorite: Boolean(item.starred) || false,
+7
View File
@@ -244,6 +244,10 @@ export const sortSongList = (songs: Song[], sortBy: SongListSort, sortOrder: Sor
results = orderBy(results, ['releaseDate'], [order]);
break;
case SongListSort.SORT_NAME:
results = orderBy(results, [(v) => v.sortName ?? v.name], [order]);
break;
case SongListSort.YEAR:
results = orderBy(
results,
@@ -440,6 +444,9 @@ export const sortAlbumList = (albums: Album[], sortBy: AlbumListSort, sortOrder:
case AlbumListSort.SONG_COUNT:
results = orderBy(results, ['songCount'], [order]);
break;
case AlbumListSort.SORT_NAME:
results = orderBy(results, [(v) => v.sortName ?? v.name], [order]);
break;
case AlbumListSort.YEAR:
results = orderBy(results, ['releaseYear'], [order]);
break;