Fix subsonic album list sort options
This commit is contained in:
parent
6e8ca7e035
commit
107074b240
1 changed files with 14 additions and 3 deletions
|
@ -15,6 +15,7 @@ import {
|
||||||
GenreListSort,
|
GenreListSort,
|
||||||
AlbumListSort,
|
AlbumListSort,
|
||||||
sortAlbumList,
|
sortAlbumList,
|
||||||
|
SortOrder,
|
||||||
} from '/@/renderer/api/types';
|
} from '/@/renderer/api/types';
|
||||||
import { randomString } from '/@/renderer/utils';
|
import { randomString } from '/@/renderer/utils';
|
||||||
import { ServerFeatures } from '/@/renderer/api/features-types';
|
import { ServerFeatures } from '/@/renderer/api/features-types';
|
||||||
|
@ -25,14 +26,14 @@ const ALBUM_LIST_SORT_MAPPING: Record<AlbumListSort, AlbumListSortType | undefin
|
||||||
[AlbumListSort.PLAY_COUNT]: AlbumListSortType.FREQUENT,
|
[AlbumListSort.PLAY_COUNT]: AlbumListSortType.FREQUENT,
|
||||||
[AlbumListSort.RECENTLY_ADDED]: AlbumListSortType.NEWEST,
|
[AlbumListSort.RECENTLY_ADDED]: AlbumListSortType.NEWEST,
|
||||||
[AlbumListSort.FAVORITED]: AlbumListSortType.STARRED,
|
[AlbumListSort.FAVORITED]: AlbumListSortType.STARRED,
|
||||||
[AlbumListSort.YEAR]: AlbumListSortType.RECENT,
|
[AlbumListSort.YEAR]: AlbumListSortType.BY_YEAR,
|
||||||
[AlbumListSort.NAME]: AlbumListSortType.ALPHABETICAL_BY_NAME,
|
[AlbumListSort.NAME]: AlbumListSortType.ALPHABETICAL_BY_NAME,
|
||||||
[AlbumListSort.COMMUNITY_RATING]: undefined,
|
[AlbumListSort.COMMUNITY_RATING]: undefined,
|
||||||
[AlbumListSort.DURATION]: undefined,
|
[AlbumListSort.DURATION]: undefined,
|
||||||
[AlbumListSort.CRITIC_RATING]: undefined,
|
[AlbumListSort.CRITIC_RATING]: undefined,
|
||||||
[AlbumListSort.RATING]: undefined,
|
[AlbumListSort.RATING]: undefined,
|
||||||
[AlbumListSort.ARTIST]: undefined,
|
[AlbumListSort.ARTIST]: undefined,
|
||||||
[AlbumListSort.RECENTLY_PLAYED]: undefined,
|
[AlbumListSort.RECENTLY_PLAYED]: AlbumListSortType.RECENT,
|
||||||
[AlbumListSort.RELEASE_DATE]: undefined,
|
[AlbumListSort.RELEASE_DATE]: undefined,
|
||||||
[AlbumListSort.SONG_COUNT]: undefined,
|
[AlbumListSort.SONG_COUNT]: undefined,
|
||||||
};
|
};
|
||||||
|
@ -360,6 +361,16 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === AlbumListSortType.BY_YEAR && !fromYear && !toYear) {
|
||||||
|
if (query.sortOrder === SortOrder.ASC) {
|
||||||
|
fromYear = 0;
|
||||||
|
toYear = dayjs().year();
|
||||||
|
} else {
|
||||||
|
fromYear = dayjs().year();
|
||||||
|
toYear = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const res = await ssApiClient(apiClientProps).getAlbumList2({
|
const res = await ssApiClient(apiClientProps).getAlbumList2({
|
||||||
query: {
|
query: {
|
||||||
fromYear,
|
fromYear,
|
||||||
|
@ -436,7 +447,7 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
return (res.body.starred?.album || []).length || 0;
|
return (res.body.starred?.album || []).length || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = ALBUM_LIST_SORT_MAPPING[query.sortBy] ?? AlbumListSortType.ALPHABETICAL_BY_NAME;
|
let type = AlbumListSortType.ALPHABETICAL_BY_NAME;
|
||||||
|
|
||||||
let fetchNextPage = true;
|
let fetchNextPage = true;
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
|
|
Reference in a new issue