mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
add SortName client side sort option (#1612)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -192,6 +192,7 @@ export type Album = {
|
||||
size: null | number;
|
||||
songCount: null | number;
|
||||
songs?: Song[];
|
||||
sortName: string;
|
||||
tags: null | Record<string, string[]>;
|
||||
updatedAt: string;
|
||||
userFavorite: boolean;
|
||||
@@ -392,6 +393,7 @@ export type Song = {
|
||||
releaseYear: null | number;
|
||||
sampleRate: null | number;
|
||||
size: number;
|
||||
sortName: string;
|
||||
tags: null | Record<string, string[]>;
|
||||
trackNumber: number;
|
||||
trackSubtitle: null | string;
|
||||
@@ -464,6 +466,7 @@ export enum AlbumListSort {
|
||||
RECENTLY_PLAYED = 'recentlyPlayed',
|
||||
RELEASE_DATE = 'releaseDate',
|
||||
SONG_COUNT = 'songCount',
|
||||
SORT_NAME = 'sortName',
|
||||
YEAR = 'year',
|
||||
}
|
||||
|
||||
@@ -518,6 +521,7 @@ export const albumListSortMap: AlbumListSortMap = {
|
||||
recentlyPlayed: undefined,
|
||||
releaseDate: JFAlbumListSort.RELEASE_DATE,
|
||||
songCount: undefined,
|
||||
sortName: JFAlbumListSort.NAME,
|
||||
year: undefined,
|
||||
},
|
||||
navidrome: {
|
||||
@@ -537,6 +541,7 @@ export const albumListSortMap: AlbumListSortMap = {
|
||||
// Recent versions of Navidrome support release date, but fallback to year for now
|
||||
releaseDate: NDAlbumListSort.YEAR,
|
||||
songCount: NDAlbumListSort.SONG_COUNT,
|
||||
sortName: NDAlbumListSort.NAME,
|
||||
year: NDAlbumListSort.YEAR,
|
||||
},
|
||||
subsonic: {
|
||||
@@ -555,6 +560,7 @@ export const albumListSortMap: AlbumListSortMap = {
|
||||
recentlyPlayed: undefined,
|
||||
releaseDate: undefined,
|
||||
songCount: undefined,
|
||||
sortName: undefined,
|
||||
year: undefined,
|
||||
},
|
||||
};
|
||||
@@ -578,6 +584,7 @@ export enum SongListSort {
|
||||
RECENTLY_ADDED = 'recentlyAdded',
|
||||
RECENTLY_PLAYED = 'recentlyPlayed',
|
||||
RELEASE_DATE = 'releaseDate',
|
||||
SORT_NAME = 'sortName',
|
||||
YEAR = 'year',
|
||||
}
|
||||
|
||||
@@ -642,6 +649,7 @@ export const songListSortMap: SongListSortMap = {
|
||||
recentlyAdded: JFSongListSort.RECENTLY_ADDED,
|
||||
recentlyPlayed: JFSongListSort.RECENTLY_PLAYED,
|
||||
releaseDate: JFSongListSort.RELEASE_DATE,
|
||||
sortName: JFSongListSort.NAME,
|
||||
year: undefined,
|
||||
},
|
||||
navidrome: {
|
||||
@@ -663,6 +671,7 @@ export const songListSortMap: SongListSortMap = {
|
||||
recentlyAdded: NDSongListSort.RECENTLY_ADDED,
|
||||
recentlyPlayed: NDSongListSort.PLAY_DATE,
|
||||
releaseDate: undefined,
|
||||
sortName: NDSongListSort.TITLE,
|
||||
year: NDSongListSort.YEAR,
|
||||
},
|
||||
subsonic: {
|
||||
@@ -684,6 +693,7 @@ export const songListSortMap: SongListSortMap = {
|
||||
recentlyAdded: undefined,
|
||||
recentlyPlayed: undefined,
|
||||
releaseDate: undefined,
|
||||
sortName: undefined,
|
||||
year: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user