removed extra if

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-08-27 20:02:12 +03:00
parent 4036cecfc0
commit 8c607ae734
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
3 changed files with 19 additions and 31 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;