Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/DrENDzZ/feishin into…
Browse files Browse the repository at this point in the history
… development
  • Loading branch information
ENDlezZenith committed Sep 19, 2024
2 parents 063b419 + 41b5635 commit 942c55d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/renderer/api/navidrome.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ export type NDAlbumListParams = {
NDOrder;

export enum NDSongListSort {
ALBUM = 'album, order_album_artist_name, disc_number, track_number, title',
ALBUM_ARTIST = 'order_album_artist_name, album, disc_number, track_number, title',
ALBUM_SONGS = 'album, discNumber, trackNumber',
ALBUM = 'album',
ALBUM_ARTIST = 'order_album_artist_name',
ALBUM_SONGS = 'album',
ARTIST = 'artist',
BPM = 'bpm',
CHANNELS = 'channels',
COMMENT = 'comment',
DURATION = 'duration',
FAVORITED = 'starred ASC, starredAt ASC',
FAVORITED = 'starred',
GENRE = 'genre',
ID = 'id',
PLAY_COUNT = 'playCount',
Expand All @@ -247,7 +247,7 @@ export enum NDSongListSort {
RECENTLY_ADDED = 'createdAt',
TITLE = 'title',
TRACK = 'track',
YEAR = 'year, album, discNumber, trackNumber',
YEAR = 'year',
}

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

export enum NDAlbumArtistListSort {
ALBUM_COUNT = 'albumCount',
FAVORITED = 'starred ASC, starredAt ASC',
FAVORITED = 'starred',
NAME = 'name',
PLAY_COUNT = 'playCount',
RATING = 'rating',
Expand Down
29 changes: 29 additions & 0 deletions src/renderer/api/navidrome/navidrome-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ 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 @@ -285,6 +286,34 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const ShuffleAllModal = ({
max={500}
min={1}
value={limit}
onChange={(e) => setStore({ limit: e ? Number(e) : 0 })}
onChange={(e) => setStore({ limit: e ? Number(e) : 500 })}
/>
<Group grow>
<NumberInput
Expand Down Expand Up @@ -208,6 +208,7 @@ export const ShuffleAllModal = ({
<Divider />
<Group grow>
<Button
disabled={!limit}
leftIcon={<RiAddBoxFill size="1rem" />}
type="submit"
variant="default"
Expand All @@ -216,6 +217,7 @@ export const ShuffleAllModal = ({
Add
</Button>
<Button
disabled={!limit}
leftIcon={<RiAddCircleFill size="1rem" />}
type="submit"
variant="default"
Expand All @@ -225,6 +227,7 @@ export const ShuffleAllModal = ({
</Button>
</Group>
<Button
disabled={!limit}
leftIcon={<RiPlayFill size="1rem" />}
type="submit"
variant="filled"
Expand Down

0 comments on commit 942c55d

Please sign in to comment.