aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/flame
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-03-07 16:22:57 -0300
committerflow <thiagodonato300@gmail.com>2022-03-07 16:22:57 -0300
commitf714adf6d2cc94f20ba37f2776d0d61e22267f0e (patch)
treea72a3f07b0edc45e8c07f97daa8b2786d7cf3ad3 /launcher/ui/pages/modplatform/flame
parent39bd04f06ff42623f7349096d707c4a877fc7cd7 (diff)
downloadPrismLauncher-f714adf6d2cc94f20ba37f2776d0d61e22267f0e.tar.gz
PrismLauncher-f714adf6d2cc94f20ba37f2776d0d61e22267f0e.tar.bz2
PrismLauncher-f714adf6d2cc94f20ba37f2776d0d61e22267f0e.zip
refactor: move NetJob away from ModModel to ModAPI
This is done so that 1. ModAPI behaves more like an actual API instead of just a helper, and 2. Allows for more easily creating other mod providers that may or may not use network tasks (foreshadowing lol)
Diffstat (limited to 'launcher/ui/pages/modplatform/flame')
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.cpp10
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.h2
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp12
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.h2
4 files changed, 6 insertions, 20 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
index 283f9ce7..cff29a79 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
@@ -11,18 +11,10 @@ ListModel::ListModel(FlameModPage* parent) : ModPlatform::ListModel(parent) {}
ListModel::~ListModel() {}
-void FlameMod::ListModel::searchRequestFinished()
+void FlameMod::ListModel::searchRequestFinished(QJsonDocument& doc)
{
jobPtr.reset();
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(response, &parse_error);
- if(parse_error.error != QJsonParseError::NoError) {
- qWarning() << "Error while parsing JSON response from Flame at " << parse_error.offset << " reason: " << parse_error.errorString();
- qWarning() << response;
- return;
- }
-
QList<ModPlatform::IndexedPack> newList;
auto packs = doc.array();
for(auto packRaw : packs) {
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.h b/launcher/ui/pages/modplatform/flame/FlameModModel.h
index ae919e63..022ec32e 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModModel.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModModel.h
@@ -30,7 +30,7 @@ class ListModel : public ModPlatform::ListModel {
virtual ~ListModel();
private slots:
- void searchRequestFinished() override;
+ void searchRequestFinished(QJsonDocument& doc) override;
private:
const char** getSorts() const override;
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
index 6564265c..19f58280 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
@@ -36,23 +36,17 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance* instance)
bool FlameModPage::shouldDisplay() const { return true; }
-void FlameModPage::onRequestVersionsSucceeded(ModPage* instance, QByteArray* response, QString addonId)
+void FlameModPage::onRequestVersionsSucceeded(QJsonDocument& doc, QString addonId)
{
if (addonId != current.addonId) {
return; // wrong request
}
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
- if (parse_error.error != QJsonParseError::NoError) {
- qWarning() << "Error while parsing JSON response from Flame at " << parse_error.offset << " reason: " << parse_error.errorString();
- qWarning() << *response;
- return;
- }
+
QJsonArray arr = doc.array();
try {
FlameMod::loadIndexedPackVersions(current, arr, APPLICATION->network(), m_instance);
} catch (const JSONValidationError& e) {
- qDebug() << *response;
+ qDebug() << doc;
qWarning() << "Error while reading Flame mod version: " << e.cause();
}
auto packProfile = ((MinecraftInstance*)m_instance)->getPackProfile();
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h
index 9c6f0e6c..f15b51ec 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h
@@ -22,5 +22,5 @@ class FlameModPage : public ModPage {
bool shouldDisplay() const override;
private:
- void onRequestVersionsSucceeded(ModPage*, QByteArray*, QString) override;
+ void onRequestVersionsSucceeded(QJsonDocument&, QString) override;
};