diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2018-07-20 03:21:30 -0500 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2018-07-22 14:28:38 -0500 |
| commit | fc8a6b358fb7bda18979c7c5c23c13d7c2ae8dc8 (patch) | |
| tree | 96495b386798a1ac71726d58164d06dcdc450ddb /src | |
| parent | edf608ab23e98b4d7dbfd09628cb64770d4bdb1a (diff) | |
Improve robustness of endorsement checks
At times, the voted_by_user item is returned as Invalid. toBool() causes this to be false, meaning the item is seen as not endorsed. Now, the endorsement state is not checked if the data is invalid.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c9874b20..d8dd6e45 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4388,7 +4388,8 @@ void MainWindow::nxmUpdatesAvailable(const std::vector<int> &modIDs, QVariant us if (game
&& result["id"].toInt() == game->nexusModOrganizerID()
&& result["game_id"].toInt() == game->nexusGameID()) {
- if (!result["voted_by_user"].toBool()) {
+ if (result["voted_by_user"].type() != QVariant::Invalid &&
+ !result["voted_by_user"].toBool()) {
ui->actionEndorseMO->setVisible(true);
}
} else {
@@ -4412,7 +4413,8 @@ void MainWindow::nxmUpdatesAvailable(const std::vector<int> &modIDs, QVariant us (*iter)->setNewestVersion(result["version"].toString());
(*iter)->setNexusDescription(result["description"].toString());
if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->loggedIn() &&
- result.contains("voted_by_user")) {
+ result.contains("voted_by_user") &&
+ result["voted_by_user"].type() != QVariant::Invalid) {
// don't use endorsement info if we're not logged in or if the response doesn't contain it
(*iter)->setIsEndorsed(result["voted_by_user"].toBool());
}
|
