Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Un-)endorse & (un-)track mods from the same source #2141

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
43 changes: 24 additions & 19 deletions src/modinforegular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,26 +369,33 @@ 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;
QMutexLocker locker(&s_Mutex);
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();
QMutexLocker locker(&s_Mutex);
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);
}

Expand Down Expand Up @@ -583,11 +590,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()
Expand Down
Loading