refactor(RD): clear up sorting methods

This refactors the sorting methods to join every bit of it into a single
list, easing maintanance. It also removes the weird index contraint on
the list of methods by adding an index field to the DS that holds the
method.

Lastly, it puts the available methods on their respective API, so other
resources on the same API can re-use them later on.

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-12-20 12:15:17 -03:00
parent c8eca4fb85
commit 36571c5e22
17 changed files with 93 additions and 61 deletions

View File

@ -49,6 +49,8 @@ class ModrinthAPI : public NetworkResourceAPI {
NetJob::Ptr getProjects(QStringList addonIds, QByteArray* response) const override;
public:
[[nodiscard]] auto getSortingMethods() const -> QList<ResourceAPI::SortingMethod> override;
inline auto getAuthorURL(const QString& name) const -> QString { return "https://modrinth.com/user/" + name; };
static auto getModLoaderStrings(const ModLoaderTypes types) -> const QStringList
@ -116,7 +118,7 @@ class ModrinthAPI : public NetworkResourceAPI {
if (args.search.has_value())
get_arguments.append(QString("query=%1").arg(args.search.value()));
if (args.sorting.has_value())
get_arguments.append(QString("index=%1").arg(args.sorting.value()));
get_arguments.append(QString("index=%1").arg(args.sorting.value().name));
get_arguments.append(QString("facets=%1").arg(createFacets(args)));
return BuildConfig.MODRINTH_PROD_URL + "/search?" + get_arguments.join('&');