From 8c607ae7348206c29a8a8ce5e2db421138bd89ff Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 27 Aug 2023 20:02:12 +0300 Subject: [PATCH] removed extra if Signed-off-by: Trial97 --- .../ui/pages/modplatform/ResourceModel.cpp | 34 ++++++++----------- .../ui/pages/modplatform/flame/FlameModel.cpp | 8 ++--- .../modplatform/modrinth/ModrinthModel.cpp | 8 ++--- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/launcher/ui/pages/modplatform/ResourceModel.cpp b/launcher/ui/pages/modplatform/ResourceModel.cpp index 018721f94..cb8f1920f 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.cpp +++ b/launcher/ui/pages/modplatform/ResourceModel.cpp @@ -137,26 +137,22 @@ void ResourceModel::search() if (!projectId.isEmpty()) { ResourceAPI::ProjectInfoCallbacks callbacks; - // Use defaults if no callbacks are set - if (!callbacks.on_fail) - callbacks.on_fail = [this](QString reason) { - if (!s_running_models.constFind(this).value()) - return; - searchRequestFailed(reason, -1); - }; - if (!callbacks.on_abort) - callbacks.on_abort = [this] { - if (!s_running_models.constFind(this).value()) - return; - searchRequestAborted(); - }; + callbacks.on_fail = [this](QString reason) { + if (!s_running_models.constFind(this).value()) + return; + searchRequestFailed(reason, -1); + }; + callbacks.on_abort = [this] { + if (!s_running_models.constFind(this).value()) + return; + searchRequestAborted(); + }; - if (!callbacks.on_succeed) - callbacks.on_succeed = [this](auto& doc, auto& pack) { - if (!s_running_models.constFind(this).value()) - return; - searchRequestForOneSucceeded(doc); - }; + callbacks.on_succeed = [this](auto& doc, auto& pack) { + if (!s_running_models.constFind(this).value()) + return; + searchRequestForOneSucceeded(doc); + }; if (auto job = m_api->getProjectInfo({ projectId }, std::move(callbacks)); job) runSearchJob(job); return; diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModel.cpp index 17875a604..8875a9452 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModel.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModel.cpp @@ -168,12 +168,8 @@ void ListModel::performPaginatedSearch() if (!projectId.isEmpty()) { ResourceAPI::ProjectInfoCallbacks callbacks; - // Use defaults if no callbacks are set - if (!callbacks.on_fail) - callbacks.on_fail = [this](QString reason) { searchRequestFailed(reason); }; - - if (!callbacks.on_succeed) - callbacks.on_succeed = [this](auto& doc, auto& pack) { searchRequestForOneSucceeded(doc); }; + callbacks.on_fail = [this](QString reason) { searchRequestFailed(reason); }; + callbacks.on_succeed = [this](auto& doc, auto& pack) { searchRequestForOneSucceeded(doc); }; static const FlameAPI api; if (auto job = api.getProjectInfo({ projectId }, std::move(callbacks)); job) { jobPtr = job; diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp index efb1fe44e..f691a185d 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp @@ -138,12 +138,8 @@ void ModpackListModel::performPaginatedSearch() if (!projectId.isEmpty()) { ResourceAPI::ProjectInfoCallbacks callbacks; - // Use defaults if no callbacks are set - if (!callbacks.on_fail) - callbacks.on_fail = [this](QString reason) { searchRequestFailed(reason); }; - - if (!callbacks.on_succeed) - callbacks.on_succeed = [this](auto& doc, auto& pack) { searchRequestForOneSucceeded(doc); }; + callbacks.on_fail = [this](QString reason) { searchRequestFailed(reason); }; + callbacks.on_succeed = [this](auto& doc, auto& pack) { searchRequestForOneSucceeded(doc); }; static const ModrinthAPI api; if (auto job = api.getProjectInfo({ projectId }, std::move(callbacks)); job) { jobPtr = job;