Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Davilarek committed Dec 3, 2023
1 parent 7e16af9 commit 2f6c062
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ const SortDirection = {
},
};

/**
* @param {string} sortMode
*/
const AutomaticSortDirection = (sortMode) => {
if (sortMode === SortMode.alphabetically) {
return SortDirection.ascending;
}
if (sortMode === SortMode.date) {
// technically this is wrong but it's a workaround
return SortDirection.ascending;
}
return SortDirection.descending;
};

const TekstowoAPIUrls = {
/**
* @param {TekstowoAPILyricsID} id
Expand All @@ -94,7 +108,7 @@ const TekstowoAPIUrls = {
/**
* @param {TekstowoAPIArtistID} id
*/
ARTIST_SONGS: (id, sortMode = SortMode.alphabetically, sortDir = (sortMode == SortMode.alphabetically ? SortDirection.ascending : SortDirection.descending), page = 1) => {
ARTIST_SONGS: (id, sortMode = SortMode.alphabetically, sortDir = (AutomaticSortDirection(sortMode)), page = 1) => {
return `https://www.tekstowo.pl/piosenki_artysty,${id},${sortMode},${sortDir},strona,${page}.html`;
},
};
Expand Down

0 comments on commit 2f6c062

Please sign in to comment.