Only count approved addons for indicator

This commit is contained in:
Benau 2020-12-01 16:17:47 +08:00
parent 61833c9c26
commit 85984d143a
3 changed files with 13 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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')") );