change: use build variables for the modrinth API URLs

Make it more consistent with the others
This commit is contained in:
flow 2022-05-15 07:43:02 -03:00
parent 4a0e4fdb85
commit 4bb429a0fb
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
4 changed files with 21 additions and 15 deletions

View File

@ -151,6 +151,9 @@ class Config {
*/ */
QString TECHNIC_API_BUILD = "multimc"; QString TECHNIC_API_BUILD = "multimc";
QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2";
QString MODRINTH_PROD_URL = "https://api.modrinth.com/v2";
/** /**
* \brief Converts the Version to a string. * \brief Converts the Version to a string.
* \return The version number in string format (major.minor.revision.build). * \return The version number in string format (major.minor.revision.build).

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "BuildConfig.h"
#include "modplatform/ModAPI.h" #include "modplatform/ModAPI.h"
#include "modplatform/helpers/NetworkModAPI.h" #include "modplatform/helpers/NetworkModAPI.h"
@ -47,13 +48,13 @@ class ModrinthAPI : public NetworkModAPI {
return ""; return "";
} }
return QString( return QString(BuildConfig.MODRINTH_PROD_URL +
"https://api.modrinth.com/v2/search?" "/search?"
"offset=%1&" "offset=%1&"
"limit=25&" "limit=25&"
"query=%2&" "query=%2&"
"index=%3&" "index=%3&"
"facets=[[%4],%5[\"project_type:mod\"]]") "facets=[[%4],%5[\"project_type:mod\"]]")
.arg(args.offset) .arg(args.offset)
.arg(args.search) .arg(args.search)
.arg(args.sorting) .arg(args.sorting)
@ -63,9 +64,10 @@ class ModrinthAPI : public NetworkModAPI {
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
{ {
return QString("https://api.modrinth.com/v2/project/%1/version?" return QString(BuildConfig.MODRINTH_PROD_URL +
"game_versions=[%2]" "/project/%1/version?"
"loaders=[\"%3\"]") "game_versions=[%2]"
"loaders=[\"%3\"]")
.arg(args.addonId) .arg(args.addonId)
.arg(getGameVersionsString(args.mcVersions)) .arg(getGameVersionsString(args.mcVersions))
.arg(getModLoaderStrings(args.loader).join("\",\"")); .arg(getModLoaderStrings(args.loader).join("\",\""));

View File

@ -71,10 +71,10 @@ void ModpackListModel::performPaginatedSearch()
// TODO: Move to standalone API // TODO: Move to standalone API
NetJob* netJob = new NetJob("Modrinth::SearchModpack", APPLICATION->network()); NetJob* netJob = new NetJob("Modrinth::SearchModpack", APPLICATION->network());
auto searchAllUrl = QString( auto searchAllUrl = QString(
"https://staging-api.modrinth.com/v2/search?" "%1/search?"
"query=%1&" "query=%2&"
"facets=[[\"project_type:modpack\"]]") "facets=[[\"project_type:modpack\"]]")
.arg(currentSearchTerm); .arg(BuildConfig.MODRINTH_STAGING_URL, currentSearchTerm);
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchAllUrl), &m_all_response)); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchAllUrl), &m_all_response));

View File

@ -38,6 +38,7 @@
#include "ModrinthModel.h" #include "ModrinthModel.h"
#include "BuildConfig.h"
#include "InstanceImportTask.h" #include "InstanceImportTask.h"
#include "Json.h" #include "Json.h"
@ -122,7 +123,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
QString id = current.id; QString id = current.id;
netJob->addNetAction(Net::Download::makeByteArray(QString("https://staging-api.modrinth.com/v2/project/%1").arg(id), response)); netJob->addNetAction(Net::Download::makeByteArray(QString("%1/project/%2").arg(BuildConfig.MODRINTH_STAGING_URL, id), response));
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, id] { QObject::connect(netJob, &NetJob::succeeded, this, [this, response, id] {
if (id != current.id) { if (id != current.id) {
@ -167,7 +168,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
QString id = current.id; QString id = current.id;
netJob->addNetAction( netJob->addNetAction(
Net::Download::makeByteArray(QString("https://staging-api.modrinth.com/v2/project/%1/version").arg(id), response)); Net::Download::makeByteArray(QString("%1/project/%2/version").arg(BuildConfig.MODRINTH_STAGING_URL, id), response));
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, id] { QObject::connect(netJob, &NetJob::succeeded, this, [this, response, id] {
if (id != current.id) { if (id != current.id) {