Update Navidrome list sort mappings for ND v0.53.2 (#754)
* Update navidrome list sort mappings * Rename ownerName to owner_name * Remove deprecated client-side sort
This commit is contained in:
parent
28c12496f1
commit
e3946a9413
2 changed files with 5 additions and 34 deletions
|
@ -199,17 +199,17 @@ export type NDGenreListParams = {
|
||||||
NDOrder;
|
NDOrder;
|
||||||
|
|
||||||
export enum NDAlbumListSort {
|
export enum NDAlbumListSort {
|
||||||
ALBUM_ARTIST = 'albumArtist',
|
ALBUM_ARTIST = 'album_artist',
|
||||||
ARTIST = 'artist',
|
ARTIST = 'artist',
|
||||||
DURATION = 'duration',
|
DURATION = 'duration',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
PLAY_COUNT = 'playCount',
|
PLAY_COUNT = 'play_count',
|
||||||
PLAY_DATE = 'play_date',
|
PLAY_DATE = 'play_date',
|
||||||
RANDOM = 'random',
|
RANDOM = 'random',
|
||||||
RATING = 'rating',
|
RATING = 'rating',
|
||||||
RECENTLY_ADDED = 'recently_added',
|
RECENTLY_ADDED = 'recently_added',
|
||||||
SONG_COUNT = 'songCount',
|
SONG_COUNT = 'songCount',
|
||||||
STARRED = 'starred',
|
STARRED = 'starred_at',
|
||||||
YEAR = 'max_year',
|
YEAR = 'max_year',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ export type NDSongListParams = {
|
||||||
|
|
||||||
export enum NDAlbumArtistListSort {
|
export enum NDAlbumArtistListSort {
|
||||||
ALBUM_COUNT = 'albumCount',
|
ALBUM_COUNT = 'albumCount',
|
||||||
FAVORITED = 'starred',
|
FAVORITED = 'starred_at',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
PLAY_COUNT = 'playCount',
|
PLAY_COUNT = 'playCount',
|
||||||
RATING = 'rating',
|
RATING = 'rating',
|
||||||
|
@ -353,7 +353,7 @@ export type NDPlaylistListResponse = NDPlaylist[];
|
||||||
export enum NDPlaylistListSort {
|
export enum NDPlaylistListSort {
|
||||||
DURATION = 'duration',
|
DURATION = 'duration',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
OWNER = 'ownerName',
|
OWNER = 'owner_name',
|
||||||
PUBLIC = 'public',
|
PUBLIC = 'public',
|
||||||
SONG_COUNT = 'songCount',
|
SONG_COUNT = 'songCount',
|
||||||
UPDATED_AT = 'updatedAt',
|
UPDATED_AT = 'updatedAt',
|
||||||
|
|
|
@ -50,7 +50,6 @@ import {
|
||||||
SimilarSongsArgs,
|
SimilarSongsArgs,
|
||||||
Song,
|
Song,
|
||||||
MoveItemArgs,
|
MoveItemArgs,
|
||||||
SongListSort,
|
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { VersionInfo, getFeatures, hasFeature } from '/@/renderer/api/utils';
|
import { VersionInfo, getFeatures, hasFeature } from '/@/renderer/api/utils';
|
||||||
import { ServerFeature, ServerFeatures } from '/@/renderer/api/features-types';
|
import { ServerFeature, ServerFeatures } from '/@/renderer/api/features-types';
|
||||||
|
@ -286,34 +285,6 @@ const getSongList = async (args: SongListArgs): Promise<SongListResponse> => {
|
||||||
throw new Error('Failed to get song list');
|
throw new Error('Failed to get song list');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
(query.sortBy === SongListSort.ALBUM || query.sortBy === SongListSort.ALBUM_ARTIST) &&
|
|
||||||
!query.limit
|
|
||||||
) {
|
|
||||||
const isAlbumArtist = query.sortBy === SongListSort.ALBUM_ARTIST;
|
|
||||||
|
|
||||||
res.body.data.sort((a, b) => {
|
|
||||||
if (isAlbumArtist) {
|
|
||||||
const albumDiff = a.album.localeCompare(b.album);
|
|
||||||
if (albumDiff !== 0) {
|
|
||||||
return albumDiff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const discDiff = a.discNumber - b.discNumber;
|
|
||||||
if (discDiff !== 0) {
|
|
||||||
return discDiff;
|
|
||||||
}
|
|
||||||
|
|
||||||
const trackDiff = a.trackNumber - b.trackNumber;
|
|
||||||
if (trackDiff !== 0) {
|
|
||||||
return trackDiff;
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.title.localeCompare(b.title);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: res.body.data.map((song) =>
|
items: res.body.data.map((song) =>
|
||||||
ndNormalize.song(song, apiClientProps.server, '', query.imageSize),
|
ndNormalize.song(song, apiClientProps.server, '', query.imageSize),
|
||||||
|
|
Reference in a new issue