mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
handle sanitized sort and filter post-fact
This commit is contained in:
parent
b628b684ae
commit
6eecc3c0fd
2 changed files with 35 additions and 6 deletions
|
|
@ -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';
|
||||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue