From ef76fe404261242d2c7cfa9b070687e84deb4272 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Sat, 12 Oct 2024 22:58:55 +0200 Subject: [PATCH] (Un-)endorse & (un-)track mods from the same source --- src/mainwindow.cpp | 14 ++++++++------ src/modinforegular.cpp | 41 ++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f346a3e44..04ea75439 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3068,12 +3068,14 @@ void MainWindow::nxmEndorsementsAvailable(QVariant userData, QVariant resultData ModInfo::getByModID(result->first, result->second.first); for (auto mod : modsList) { - if (result->second.second == "Endorsed") - mod->setIsEndorsed(true); - else if (result->second.second == "Abstained") - mod->setNeverEndorse(); - else - mod->setIsEndorsed(false); + if (mod->endorsedState() != EndorsedState::ENDORSED_NEVER) { + if (result->second.second == "Endorsed") + mod->setIsEndorsed(true); + else if (result->second.second == "Abstained") + mod->setNeverEndorse(); + else + mod->setIsEndorsed(false); + } } if (Settings::instance().nexus().endorsementIntegration()) { diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index d3ff65472..606b14cb6 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -369,26 +369,31 @@ void ModInfoRegular::nxmDescriptionAvailable(QString, int, QVariant, void ModInfoRegular::nxmEndorsementToggled(QString, int, QVariant, QVariant resultData) { QMap results = resultData.toMap(); - if (results["status"].toString().compare("Endorsed") == 0) { - m_EndorsedState = EndorsedState::ENDORSED_TRUE; - } else if (results["status"].toString().compare("Abstained") == 0) { - m_EndorsedState = EndorsedState::ENDORSED_NEVER; - } else { - m_EndorsedState = EndorsedState::ENDORSED_FALSE; + for (auto& mod : s_Collection) { + if (mod->gameName().compare(m_GameName, Qt::CaseInsensitive) == 0 && + mod->nexusId() == m_NexusID) { + if (results["status"].toString().compare("Endorsed") == 0) { + mod->setIsEndorsed(true); + } else if (results["status"].toString().compare("Abstained") == 0) { + mod->setNeverEndorse(); + } else { + mod->setIsEndorsed(false); + } + mod->saveMeta(); + } } - m_MetaInfoChanged = true; - saveMeta(); emit modDetailsUpdated(true); } void ModInfoRegular::nxmTrackingToggled(QString, int, QVariant, bool tracked) { - if (tracked) - m_TrackedState = TrackedState::TRACKED_TRUE; - else - m_TrackedState = TrackedState::TRACKED_FALSE; - m_MetaInfoChanged = true; - saveMeta(); + for (auto& mod : s_Collection) { + if (mod->gameName().compare(m_GameName, Qt::CaseInsensitive) == 0 && + mod->nexusId() == m_NexusID) { + mod->setIsTracked(tracked); + mod->saveMeta(); + } + } emit modDetailsUpdated(true); } @@ -583,11 +588,9 @@ void ModInfoRegular::addNexusCategory(int categoryID) void ModInfoRegular::setIsEndorsed(bool endorsed) { - if (m_EndorsedState != EndorsedState::ENDORSED_NEVER) { - m_EndorsedState = - endorsed ? EndorsedState::ENDORSED_TRUE : EndorsedState::ENDORSED_FALSE; - m_MetaInfoChanged = true; - } + m_EndorsedState = + endorsed ? EndorsedState::ENDORSED_TRUE : EndorsedState::ENDORSED_FALSE; + m_MetaInfoChanged = true; } void ModInfoRegular::setNeverEndorse()