From 85984d143a78f1957d70e2f6c8263387361bbdb0 Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 1 Dec 2020 16:17:47 +0800 Subject: [PATCH] Only count approved addons for indicator --- src/addons/addons_manager.cpp | 13 +++++++------ src/addons/addons_manager.hpp | 2 +- src/config/user_config.hpp | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/addons/addons_manager.cpp b/src/addons/addons_manager.cpp index 93c0237f9..be8043bc8 100644 --- a/src/addons/addons_manager.cpp +++ b/src/addons/addons_manager.cpp @@ -127,7 +127,6 @@ void AddonsManager::init(const XMLNode *xml, && UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED && !file_manager->fileExists(filename_part); - int timestamp_check = -1; if (download) { Log::info("addons", "Downloading updated addons.xml."); @@ -140,7 +139,6 @@ void AddonsManager::init(const XMLNode *xml, download_request->getDownloadErrorMessage()); return; } - timestamp_check = UserConfigParams::m_addons_last_updated; UserConfigParams::m_addons_last_updated=StkTime::getTimeSinceEpoch(); } else @@ -157,7 +155,7 @@ void AddonsManager::init(const XMLNode *xml, } if (!xml_addons) return; - addons_manager->initAddons(xml_addons, timestamp_check); // will free xml_addons + addons_manager->initAddons(xml_addons); // will free xml_addons if(UserConfigParams::logAddons()) Log::info("addons", "Addons manager list downloaded."); } // init @@ -169,9 +167,8 @@ void AddonsManager::init(const XMLNode *xml, * without blocking the GUI. This function will update the state variable. * \param xml The xml tree of addons.xml with information about all available * addons. - * \param timestamp_check To determine m_has_new_addons. */ -void AddonsManager::initAddons(const XMLNode *xml, int timestamp_check) +void AddonsManager::initAddons(const XMLNode *xml) { m_addons_list.lock(); // Clear the list in case that a reinit is being done. @@ -190,8 +187,12 @@ void AddonsManager::initAddons(const XMLNode *xml, int timestamp_check) node->getName()=="arena" ) { Addon addon(*node); - if (timestamp_check != -1 && addon.getDate() > timestamp_check) + if (addon.testStatus(Addon::AS_APPROVED) && + addon.getDate() > UserConfigParams::m_latest_addon_time) + { m_has_new_addons = true; + UserConfigParams::m_latest_addon_time = addon.getDate(); + } int index = getAddonIndex(addon.getId()); int stk_version=0; diff --git a/src/addons/addons_manager.hpp b/src/addons/addons_manager.hpp index f35bc9eb1..816e29f8a 100644 --- a/src/addons/addons_manager.hpp +++ b/src/addons/addons_manager.hpp @@ -69,7 +69,7 @@ public: AddonsManager(); ~AddonsManager(); void init(const XMLNode *xml, bool force_refresh); - void initAddons(const XMLNode *xml, int timestamp_check = -1); + void initAddons(const XMLNode *xml); void checkInstalledAddons(); Addon* getAddon(const std::string &id); int getAddonIndex(const std::string &id) const; diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 902e7605d..a0c7e3638 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -1138,6 +1138,11 @@ namespace UserConfigParams &m_addon_group, "Time addon-list was updated last.") ); + PARAM_PREFIX TimeUserConfigParam m_latest_addon_time + PARAM_DEFAULT( TimeUserConfigParam(0, "latest_addon_time", + &m_addon_group, + "Latest approved addon time.") ); + PARAM_PREFIX StringUserConfigParam m_language PARAM_DEFAULT( StringUserConfigParam("system", "language", "Which language to use (language code or 'system')") );