mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-29 01:08:50 -04:00
fixed up the update of message count using a flag to only update when necessary, which limits drastically the calls to getGroupsStatistics()
This commit is contained in:
parent
65af73f8eb
commit
5c71a46c52
4 changed files with 42 additions and 16 deletions
|
@ -182,7 +182,26 @@ void GxsGroupFrameDialog::showEvent(QShowEvent *event)
|
|||
initUi();
|
||||
}
|
||||
|
||||
updateDisplay( mCachedGroupMetas.empty() );
|
||||
bool empty = mCachedGroupMetas.empty();
|
||||
|
||||
updateDisplay( empty );
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe)
|
||||
{
|
||||
if(mShouldUpdateMessageSummaryList)
|
||||
{
|
||||
if(!mGroupIdsSummaryToUpdate.empty())
|
||||
for(auto& group_id: mGroupIdsSummaryToUpdate)
|
||||
updateMessageSummaryListReal(group_id);
|
||||
else
|
||||
updateMessageSummaryListReal(RsGxsGroupId());
|
||||
|
||||
mShouldUpdateMessageSummaryList = false;
|
||||
mGroupIdsSummaryToUpdate.clear();
|
||||
}
|
||||
|
||||
MainPage::paintEvent(pe);
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::processSettings(bool load)
|
||||
|
@ -988,6 +1007,18 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGxsGenericGroupData
|
|||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
||||
{
|
||||
// groupId.isNull() means that we need to update all groups so we clear up the list of groups to update.
|
||||
|
||||
if(!groupId.isNull())
|
||||
mGroupIdsSummaryToUpdate.insert(groupId);
|
||||
else
|
||||
mGroupIdsSummaryToUpdate.clear();
|
||||
|
||||
mShouldUpdateMessageSummaryList = true;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateMessageSummaryListReal(RsGxsGroupId groupId)
|
||||
{
|
||||
if (!mInitialized) {
|
||||
return;
|
||||
|
|
|
@ -81,7 +81,8 @@ public:
|
|||
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
virtual void paintEvent(QPaintEvent *pe) override;
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
const RsGxsGroupId &groupId() { return mGroupId; }
|
||||
|
@ -159,6 +160,7 @@ private:
|
|||
|
||||
void initUi();
|
||||
|
||||
void updateMessageSummaryListReal(RsGxsGroupId groupId);
|
||||
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
||||
void groupSubscribe(bool subscribe);
|
||||
|
||||
|
@ -209,6 +211,9 @@ private:
|
|||
RsGxsGroupId mNavigatePendingGroupId;
|
||||
RsGxsMessageId mNavigatePendingMsgId;
|
||||
|
||||
bool mShouldUpdateMessageSummaryList ; // whether we should update the counting for groups. This takes some CPU so we only do it when needed.
|
||||
std::set<RsGxsGroupId> mGroupIdsSummaryToUpdate;
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
|
|
|
@ -64,8 +64,8 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
|||
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
case RsChannelEventCode::NEW_MESSAGE:
|
||||
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
||||
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]];
|
||||
case RsChannelEventCode::UPDATED_MESSAGE:
|
||||
case RsChannelEventCode::READ_STATUS_CHANGED:
|
||||
updateMessageSummaryList(e->mChannelGroupId);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue