diff options
author | flow <flowlnlnln@gmail.com> | 2022-07-22 00:30:27 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-08-28 16:29:01 -0300 |
commit | 7b6d26990469f26dfbed6d55af25240ef0618df4 (patch) | |
tree | 40f448f5d6f796478e7376fb2b7dda25a1128d0e /launcher/ui/pages/modplatform | |
parent | 87a0482b8b299fd54691e3042ca661863ea6290a (diff) | |
download | PrismLauncher-7b6d26990469f26dfbed6d55af25240ef0618df4.tar.gz PrismLauncher-7b6d26990469f26dfbed6d55af25240ef0618df4.tar.bz2 PrismLauncher-7b6d26990469f26dfbed6d55af25240ef0618df4.zip |
refactor: make NetJob inherit from ConcurrentTask as well!
Avoids lots of code duplication
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui/pages/modplatform')
-rw-r--r-- | launcher/ui/pages/modplatform/ModModel.cpp | 5 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index 94b1f099..06a6f6b8 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -230,10 +230,11 @@ void ListModel::searchRequestFinished(QJsonDocument& doc) void ListModel::searchRequestFailed(QString reason) { - if (!jobPtr->first()->m_reply) { + auto failed_action = jobPtr->getFailedActions().at(0); + if (!failed_action->m_reply) { // Network error QMessageBox::critical(nullptr, tr("Error"), tr("A network error occurred. Could not load mods.")); - } else if (jobPtr->first()->m_reply && jobPtr->first()->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409) { + } else if (failed_action->m_reply && failed_action->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409) { // 409 Gone, notify user to update QMessageBox::critical(nullptr, tr("Error"), //: %1 refers to the launcher itself diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp index 3633d575..614be434 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp @@ -301,10 +301,11 @@ void ModpackListModel::searchRequestFinished(QJsonDocument& doc_all) void ModpackListModel::searchRequestFailed(QString reason) { - if (!jobPtr->first()->m_reply) { + auto failed_action = jobPtr->getFailedActions().at(0); + if (!failed_action->m_reply) { // Network error QMessageBox::critical(nullptr, tr("Error"), tr("A network error occurred. Could not load modpacks.")); - } else if (jobPtr->first()->m_reply && jobPtr->first()->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409) { + } else if (failed_action->m_reply && failed_action->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409) { // 409 Gone, notify user to update QMessageBox::critical(nullptr, tr("Error"), //: %1 refers to the launcher itself |