mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04:00
created a specific GxsEvent for Group Statistics changes and handle it in the GUI for all friends at once every 2 min at most
This commit is contained in:
parent
b7363b4d4e
commit
f74c65fcc0
13 changed files with 126 additions and 19 deletions
|
@ -59,6 +59,8 @@
|
|||
|
||||
#define MAX_COMMENT_TITLE 32
|
||||
|
||||
static const uint32_t DELAY_BETWEEN_GROUP_STATISTICS_UPDATE = 120; // do not update group statistics more often than once every 2 mins
|
||||
|
||||
/*
|
||||
* Transformation Notes:
|
||||
* there are still a couple of things that the new groups differ from Old version.
|
||||
|
@ -77,6 +79,8 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
|
|||
ui->setupUi(this);
|
||||
|
||||
mShouldUpdateMessageSummaryList = true;
|
||||
mShouldUpdateGroupStatistics = false;
|
||||
mLastGroupStatisticsUpdateTs=0;
|
||||
mInitialized = false;
|
||||
mDistSyncAllowed = allow_dist_sync;
|
||||
mInFill = false;
|
||||
|
@ -204,6 +208,21 @@ void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe)
|
|||
mGroupIdsSummaryToUpdate.clear();
|
||||
}
|
||||
|
||||
rstime_t now = time(nullptr);
|
||||
|
||||
if(mShouldUpdateGroupStatistics && now > DELAY_BETWEEN_GROUP_STATISTICS_UPDATE + mLastGroupStatisticsUpdateTs)
|
||||
{
|
||||
// This mechanism allows to gather multiple updateGroupStatistics events at once and not send too many of them at the same time.
|
||||
// it avoids re-loadign all the group everytime a friend sends new statistics.
|
||||
|
||||
for(auto& groupId: mGroupStatisticsToUpdate)
|
||||
updateGroupStatisticsReal(groupId);
|
||||
|
||||
mShouldUpdateGroupStatistics = false;
|
||||
mLastGroupStatisticsUpdateTs = time(nullptr);
|
||||
mGroupStatisticsToUpdate.clear();
|
||||
}
|
||||
|
||||
MainPage::paintEvent(pe);
|
||||
}
|
||||
|
||||
|
@ -1106,6 +1125,12 @@ void GxsGroupFrameDialog::updateGroupSummary()
|
|||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||
{
|
||||
mGroupStatisticsToUpdate.insert(groupId);
|
||||
mShouldUpdateGroupStatistics = true;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId)
|
||||
{
|
||||
RsThread::async([this,groupId]()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue