diff options
| author | Silarn <jrim@rimpo.org> | 2019-02-01 17:45:05 -0600 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2019-02-18 21:31:16 -0600 |
| commit | 2b5862ef0144d49e1927b5c914cbcea7183fab8a (patch) | |
| tree | 9242d5a484cb4590ff53ca17e7e1a9db33b1794e /src/modinfo.cpp | |
| parent | 78ae7072c9a0ea3795dc0610b389e8e335f4eee6 (diff) | |
Multiple updates:
* Remove periodic auto-update
* Add context menu force-update for mod list
* Fix some bugs with update parsing
- Ignore update files that are deleted
- Fix remaining issue with failing to get all mods due to capitalization
* Remove queue retry when out of requests
* Clear all requests when out of requests
* More potential improvements to login/validation process
Diffstat (limited to 'src/modinfo.cpp')
| -rw-r--r-- | src/modinfo.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/modinfo.cpp b/src/modinfo.cpp index e9cfd77b..a5b240c8 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -148,8 +148,7 @@ std::vector<ModInfo::Ptr> ModInfo::getByModID(QString game, int modID) for (auto iter : s_ModsByModID) { if (iter.first.second == modID) { if (iter.first.first.compare(game, Qt::CaseInsensitive) == 0) { - match = iter.second; - break; + match.insert(match.end(), iter.second.begin(), iter.second.end()); } } } @@ -303,6 +302,9 @@ int ModInfo::checkAllForUpdate(PluginContainer *pluginContainer, QObject *receiv } result = organizedGames.size(); + + if (organizedGames.empty()) + qWarning("All of your mods have been checked recently. We restrict update checks to help preserve your available API requests."); for (auto game : organizedGames) { NexusInterface::instance(pluginContainer)->requestUpdates(game.second, receiver, QVariant(), game.first, QString()); @@ -312,32 +314,28 @@ int ModInfo::checkAllForUpdate(PluginContainer *pluginContainer, QObject *receiv } -int ModInfo::autoUpdateCheck(PluginContainer *pluginContainer, QObject *receiver) +int ModInfo::manualUpdateCheck(PluginContainer *pluginContainer, QObject *receiver, std::multimap<QString, int> IDs) { - qInfo("Initializing periodic update check."); - int result = 0; - - std::vector<QSharedPointer<ModInfo>> sortedMods; + std::vector<QSharedPointer<ModInfo>> mods; std::multimap<QString, int> organizedGames; - for (auto mod : s_Collection) { - if (mod->canBeUpdated()) { - sortedMods.push_back(mod); - } + + for (auto ID : IDs) { + auto matchedMods = getByModID(ID.first, ID.second); + mods.insert(mods.end(), matchedMods.begin(), matchedMods.end()); } + mods.erase( + std::remove_if(mods.begin(), mods.end(), [](ModInfo::Ptr mod) -> bool { return !mod->canBeUpdated(); }), + mods.end() + ); - std::sort(sortedMods.begin(), sortedMods.end(), [](QSharedPointer<ModInfo> a, QSharedPointer<ModInfo> b) -> bool { + std::sort(mods.begin(), mods.end(), [](QSharedPointer<ModInfo> a, QSharedPointer<ModInfo> b) -> bool { return a->getLastNexusUpdate() < b->getLastNexusUpdate(); }); - if (sortedMods.size() > 10) - sortedMods.resize(10); - - result = sortedMods.size(); + if (mods.size()) { + qInfo("Checking updates for %d mods...", mods.size()); - if (sortedMods.size()) { - qInfo("Checking updates for %d mods...", sortedMods.size()); - - for (auto mod : sortedMods) { + for (auto mod : mods) { organizedGames.insert(std::make_pair<QString, int>(mod->getGameName(), mod->getNexusID())); } @@ -345,10 +343,10 @@ int ModInfo::autoUpdateCheck(PluginContainer *pluginContainer, QObject *receiver NexusInterface::instance(pluginContainer)->requestUpdates(game.second, receiver, QVariant(), game.first, QString()); } } else { - qInfo("No mods require updates at this time."); + qInfo("None of the selected mods can be updated."); } - return result; + return organizedGames.size(); } |
