summaryrefslogtreecommitdiff
path: root/src/modinfo.cpp
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2019-01-29 20:10:53 -0600
committerSilarn <jrim@rimpo.org>2019-02-18 21:29:23 -0600
commitf07f6b8904f69a92cd24e3c52eaf1fc6db8e60dd (patch)
tree8433556283b516a4dda97bbae86e6c1855e20272 /src/modinfo.cpp
parentef286a938d79f74947a392d049068e4818ccf7fd (diff)
Update Process Improvements
* 5 minute batch auto-update of up to 10 mods - Still able to force an update of all 'unchecked' mods - Prioritizes mods with oldest update 'age' * Implemented 1-hour wait between update checks per mod * Fixed issues with update progress display * Only enable update filter automatically if 'force update' * Improved display of version update status in mod list - Italic text when ready to perform update check - Tooltip indicates when next update is available * Fixed remaining issues with update fallback check * Only trigger one update API request for duplicate sources
Diffstat (limited to 'src/modinfo.cpp')
-rw-r--r--src/modinfo.cpp49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/modinfo.cpp b/src/modinfo.cpp
index e7b7657b..5d5cb57e 100644
--- a/src/modinfo.cpp
+++ b/src/modinfo.cpp
@@ -295,20 +295,63 @@ int ModInfo::checkAllForUpdate(PluginContainer *pluginContainer, QObject *receiv
// NexusInterface::instance(pluginContainer)->requestUpdates(game->nexusModOrganizerID(), receiver, QVariant(), game->gameShortName(), QString());
//}
- std::multimap<QString, QSharedPointer<ModInfo>> organizedGames;
+ std::multimap<QString, int> organizedGames;
for (auto mod : s_Collection) {
if (mod->canBeUpdated()) {
- organizedGames.insert(std::pair<QString, QSharedPointer<ModInfo>>(mod->getGameName(), mod));
+ organizedGames.insert(std::make_pair<QString, int>(mod->getGameName(), mod->getNexusID()));
}
}
+ result = organizedGames.size();
+
for (auto game : organizedGames) {
- NexusInterface::instance(pluginContainer)->requestUpdates(game.second->getNexusID(), receiver, QVariant(), game.first, QString());
+ NexusInterface::instance(pluginContainer)->requestUpdates(game.second, receiver, QVariant(), game.first, QString());
+ }
+
+ return result;
+}
+
+
+int ModInfo::autoUpdateCheck(PluginContainer *pluginContainer, QObject *receiver)
+{
+ qInfo("Initializing periodic update check.");
+ int result = 0;
+
+ std::vector<QSharedPointer<ModInfo>> sortedMods;
+ std::multimap<QString, int> organizedGames;
+ for (auto mod : s_Collection) {
+ if (mod->canBeUpdated()) {
+ sortedMods.push_back(mod);
+ }
+ }
+
+ std::sort(sortedMods.begin(), sortedMods.end(), [](QSharedPointer<ModInfo> a, QSharedPointer<ModInfo> b) -> bool {
+ return a->getLastNexusUpdate() > b->getLastNexusUpdate();
+ });
+
+ if (sortedMods.size() > 10)
+ sortedMods.resize(10);
+
+ result = sortedMods.size();
+
+ if (sortedMods.size()) {
+ qInfo("Checking updates for %d mods...", sortedMods.size());
+
+ for (auto mod : sortedMods) {
+ organizedGames.insert(std::make_pair<QString, int>(mod->getGameName(), mod->getNexusID()));
+ }
+
+ for (auto game : organizedGames) {
+ NexusInterface::instance(pluginContainer)->requestUpdates(game.second, receiver, QVariant(), game.first, QString());
+ }
+ } else {
+ qInfo("No mods require updates at this time.");
}
return result;
}
+
void ModInfo::setVersion(const VersionInfo &version)
{
m_Version = version;