fix(music#Library): sort_by err when items <= 1 (#137)

This commit is contained in:
Patrick Kan
2022-08-14 06:46:55 +08:00
committed by GitHub
parent f6a2a418be
commit 713fd13c74

View File

@@ -124,6 +124,9 @@ class Library {
if (shuffle) {
if (!shuffle_endpoint) {
if (data.items.length <= 1) {
return data;
}
throw new InnertubeError('Unable to obtain endpoint for sort_by value \'random\'');
}
return this.#fetchAndParseShuffledSongs(shuffle_endpoint);
@@ -172,6 +175,9 @@ class Library {
(item) => item.as(DropdownItem).label === SORT_BY_TEXTS[sort_by])?.as(DropdownItem);
if (!dropdownItem?.endpoint?.browse) {
if (data.items.length <= 1) {
return data;
}
throw new InnertubeError(`Unable to obtain browse endpoint for sort_by value '${sort_by}'`);
}