mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 02:50:07 -05: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
@ -335,14 +335,6 @@ RsTokenService::GxsRequestStatus RsGxsDataAccess::requestStatus(uint32_t token)
|
|||||||
uint32_t anstype;
|
uint32_t anstype;
|
||||||
rstime_t ts;
|
rstime_t ts;
|
||||||
|
|
||||||
// {
|
|
||||||
// RS_STACK_MUTEX(mDataMutex);
|
|
||||||
//
|
|
||||||
// // first check public tokens
|
|
||||||
// if(mPublicToken.find(token) != mPublicToken.end())
|
|
||||||
// return mPublicToken[token];
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!checkRequestStatus(token, status, reqtype, anstype, ts))
|
if (!checkRequestStatus(token, status, reqtype, anstype, ts))
|
||||||
return RsTokenService::FAILED;
|
return RsTokenService::FAILED;
|
||||||
|
|
||||||
@ -724,9 +716,6 @@ GxsRequest* RsGxsDataAccess::locked_retrieveCompetedRequest(const uint32_t& toke
|
|||||||
void RsGxsDataAccess::processRequests()
|
void RsGxsDataAccess::processRequests()
|
||||||
{
|
{
|
||||||
// process requests
|
// process requests
|
||||||
#ifdef DATA_DEBUG
|
|
||||||
RsDbg() << "processing requests" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (!mRequestQueue.empty())
|
while (!mRequestQueue.empty())
|
||||||
{
|
{
|
||||||
@ -762,6 +751,7 @@ void RsGxsDataAccess::processRequests()
|
|||||||
case PENDING:
|
case PENDING:
|
||||||
req = mRequestQueue.begin()->second;
|
req = mRequestQueue.begin()->second;
|
||||||
req->status = PARTIAL;
|
req->status = PARTIAL;
|
||||||
|
mRequestQueue.erase(mRequestQueue.begin()); // remove it right away from the waiting queue.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1486,7 +1476,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
|||||||
GxsMsgMetaResult metaResult;
|
GxsMsgMetaResult metaResult;
|
||||||
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
|
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
|
||||||
|
|
||||||
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
|
const std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
|
||||||
|
|
||||||
req->mGroupStatistic.mGrpId = req->mGrpId;
|
req->mGroupStatistic.mGrpId = req->mGrpId;
|
||||||
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
||||||
|
@ -182,7 +182,26 @@ void GxsGroupFrameDialog::showEvent(QShowEvent *event)
|
|||||||
initUi();
|
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)
|
void GxsGroupFrameDialog::processSettings(bool load)
|
||||||
@ -988,6 +1007,18 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGxsGenericGroupData
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
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) {
|
if (!mInitialized) {
|
||||||
return;
|
return;
|
||||||
|
@ -81,7 +81,8 @@ public:
|
|||||||
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent *event);
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
|
virtual void paintEvent(QPaintEvent *pe) override;
|
||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
const RsGxsGroupId &groupId() { return mGroupId; }
|
const RsGxsGroupId &groupId() { return mGroupId; }
|
||||||
@ -159,6 +160,7 @@ private:
|
|||||||
|
|
||||||
void initUi();
|
void initUi();
|
||||||
|
|
||||||
|
void updateMessageSummaryListReal(RsGxsGroupId groupId);
|
||||||
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
||||||
void groupSubscribe(bool subscribe);
|
void groupSubscribe(bool subscribe);
|
||||||
|
|
||||||
@ -209,6 +211,9 @@ private:
|
|||||||
RsGxsGroupId mNavigatePendingGroupId;
|
RsGxsGroupId mNavigatePendingGroupId;
|
||||||
RsGxsMessageId mNavigatePendingMsgId;
|
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;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
|
@ -64,8 +64,8 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
|||||||
|
|
||||||
switch(e->mChannelEventCode)
|
switch(e->mChannelEventCode)
|
||||||
{
|
{
|
||||||
case RsChannelEventCode::NEW_MESSAGE:
|
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]];
|
||||||
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
case RsChannelEventCode::UPDATED_MESSAGE:
|
||||||
case RsChannelEventCode::READ_STATUS_CHANGED:
|
case RsChannelEventCode::READ_STATUS_CHANGED:
|
||||||
updateMessageSummaryList(e->mChannelGroupId);
|
updateMessageSummaryList(e->mChannelGroupId);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user