Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Navidrome list sort mappings for ND v0.53.2 #754

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/renderer/api/navidrome.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,17 @@ export type NDGenreListParams = {
NDOrder;

export enum NDAlbumListSort {
ALBUM_ARTIST = 'albumArtist',
ALBUM_ARTIST = 'album_artist',
ARTIST = 'artist',
DURATION = 'duration',
NAME = 'name',
PLAY_COUNT = 'playCount',
PLAY_COUNT = 'play_count',
PLAY_DATE = 'play_date',
RANDOM = 'random',
RATING = 'rating',
RECENTLY_ADDED = 'recently_added',
SONG_COUNT = 'songCount',
STARRED = 'starred',
STARRED = 'starred_at',
YEAR = 'max_year',
}

Expand Down Expand Up @@ -261,7 +261,7 @@ export type NDSongListParams = {

export enum NDAlbumArtistListSort {
ALBUM_COUNT = 'albumCount',
FAVORITED = 'starred',
FAVORITED = 'starred_at',
NAME = 'name',
PLAY_COUNT = 'playCount',
RATING = 'rating',
Expand Down Expand Up @@ -353,7 +353,7 @@ export type NDPlaylistListResponse = NDPlaylist[];
export enum NDPlaylistListSort {
DURATION = 'duration',
NAME = 'name',
OWNER = 'ownerName',
OWNER = 'owner_name',
PUBLIC = 'public',
SONG_COUNT = 'songCount',
UPDATED_AT = 'updatedAt',
Expand Down
29 changes: 0 additions & 29 deletions src/renderer/api/navidrome/navidrome-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import {
SimilarSongsArgs,
Song,
MoveItemArgs,
SongListSort,
} from '../types';
import { VersionInfo, getFeatures, hasFeature } from '/@/renderer/api/utils';
import { ServerFeature, ServerFeatures } from '/@/renderer/api/features-types';
Expand Down Expand Up @@ -286,34 +285,6 @@ const getSongList = async (args: SongListArgs): Promise<SongListResponse> => {
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 {
items: res.body.data.map((song) =>
ndNormalize.song(song, apiClientProps.server, '', query.imageSize),
Expand Down
Loading