mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed count of new and unread messages for Channels and Posted.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7561 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3a0e944ecf
commit
37ddbf63cc
@ -1494,8 +1494,10 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
|||||||
req->mGroupStatistic.mGrpId = req->mGrpId;
|
req->mGroupStatistic.mGrpId = req->mGrpId;
|
||||||
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
||||||
req->mGroupStatistic.mTotalSizeOfMsgs = 0;
|
req->mGroupStatistic.mTotalSizeOfMsgs = 0;
|
||||||
req->mGroupStatistic.mNumMsgsNew = 0;
|
req->mGroupStatistic.mNumThreadMsgsNew = 0;
|
||||||
req->mGroupStatistic.mNumMsgsUnread = 0;
|
req->mGroupStatistic.mNumThreadMsgsUnread = 0;
|
||||||
|
req->mGroupStatistic.mNumChildMsgsNew = 0;
|
||||||
|
req->mGroupStatistic.mNumChildMsgsUnread = 0;
|
||||||
|
|
||||||
for(int i = 0; i < msgMetaV.size(); i++)
|
for(int i = 0; i < msgMetaV.size(); i++)
|
||||||
{
|
{
|
||||||
@ -1504,11 +1506,21 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
|||||||
|
|
||||||
if (IS_MSG_NEW(m->mMsgStatus))
|
if (IS_MSG_NEW(m->mMsgStatus))
|
||||||
{
|
{
|
||||||
++req->mGroupStatistic.mNumMsgsNew;
|
if (m->mParentId.isNull())
|
||||||
|
{
|
||||||
|
++req->mGroupStatistic.mNumThreadMsgsNew;
|
||||||
|
} else {
|
||||||
|
++req->mGroupStatistic.mNumChildMsgsNew;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (IS_MSG_UNREAD(m->mMsgStatus))
|
if (IS_MSG_UNREAD(m->mMsgStatus))
|
||||||
{
|
{
|
||||||
++req->mGroupStatistic.mNumMsgsUnread;
|
if (m->mParentId.isNull())
|
||||||
|
{
|
||||||
|
++req->mGroupStatistic.mNumThreadMsgsUnread;
|
||||||
|
} else {
|
||||||
|
++req->mGroupStatistic.mNumChildMsgsUnread;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1526,24 +1538,35 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
|||||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
|
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
|
||||||
|
|
||||||
req->mServiceStatistic.mNumGrps = grpMeta.size();
|
req->mServiceStatistic.mNumGrps = grpMeta.size();
|
||||||
|
req->mServiceStatistic.mNumMsgs = 0;
|
||||||
req->mServiceStatistic.mSizeOfGrps = 0;
|
req->mServiceStatistic.mSizeOfGrps = 0;
|
||||||
req->mServiceStatistic.mSizeOfMsgs = 0;
|
req->mServiceStatistic.mSizeOfMsgs = 0;
|
||||||
req->mServiceStatistic.mNumGrpsSubscribed = 0;
|
req->mServiceStatistic.mNumGrpsSubscribed = 0;
|
||||||
req->mServiceStatistic.mNumMsgsNew = 0;
|
req->mServiceStatistic.mNumThreadMsgsNew = 0;
|
||||||
req->mServiceStatistic.mNumMsgsUnread = 0;
|
req->mServiceStatistic.mNumThreadMsgsUnread = 0;
|
||||||
|
req->mServiceStatistic.mNumChildMsgsNew = 0;
|
||||||
|
req->mServiceStatistic.mNumChildMsgsUnread = 0;
|
||||||
|
|
||||||
for(; mit != grpMeta.end(); mit++)
|
for(; mit != grpMeta.end(); mit++)
|
||||||
{
|
{
|
||||||
RsGxsGrpMetaData* m = mit->second;
|
RsGxsGrpMetaData* m = mit->second;
|
||||||
req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size();
|
req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size();
|
||||||
|
|
||||||
|
if (IS_GROUP_SUBSCRIBED(m->mSubscribeFlags))
|
||||||
|
{
|
||||||
|
++req->mServiceStatistic.mNumGrpsSubscribed;
|
||||||
|
|
||||||
GroupStatisticRequest gr;
|
GroupStatisticRequest gr;
|
||||||
gr.mGrpId = m->mGroupId;
|
gr.mGrpId = m->mGroupId;
|
||||||
getGroupStatistic(&gr);
|
getGroupStatistic(&gr);
|
||||||
|
|
||||||
req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs;
|
req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs;
|
||||||
req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs;
|
req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs;
|
||||||
req->mServiceStatistic.mNumGrpsSubscribed += m->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ? 1 : 0;
|
req->mServiceStatistic.mNumThreadMsgsNew += gr.mGroupStatistic.mNumThreadMsgsNew;
|
||||||
req->mServiceStatistic.mNumMsgsNew += gr.mGroupStatistic.mNumMsgsNew;
|
req->mServiceStatistic.mNumThreadMsgsUnread += gr.mGroupStatistic.mNumThreadMsgsUnread;
|
||||||
req->mServiceStatistic.mNumMsgsUnread += gr.mGroupStatistic.mNumMsgsUnread;
|
req->mServiceStatistic.mNumChildMsgsNew += gr.mGroupStatistic.mNumChildMsgsNew;
|
||||||
|
req->mServiceStatistic.mNumChildMsgsUnread += gr.mGroupStatistic.mNumChildMsgsUnread;
|
||||||
|
}
|
||||||
|
|
||||||
delete m;
|
delete m;
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,10 @@ public:
|
|||||||
RsGxsGroupId mGrpId;
|
RsGxsGroupId mGrpId;
|
||||||
uint32_t mNumMsgs;
|
uint32_t mNumMsgs;
|
||||||
uint32_t mTotalSizeOfMsgs;
|
uint32_t mTotalSizeOfMsgs;
|
||||||
uint32_t mNumMsgsNew;
|
uint32_t mNumThreadMsgsNew;
|
||||||
uint32_t mNumMsgsUnread;
|
uint32_t mNumThreadMsgsUnread;
|
||||||
|
uint32_t mNumChildMsgsNew;
|
||||||
|
uint32_t mNumChildMsgsUnread;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GxsServiceStatistic
|
class GxsServiceStatistic
|
||||||
@ -152,8 +154,10 @@ public:
|
|||||||
uint32_t mSizeOfMsgs;
|
uint32_t mSizeOfMsgs;
|
||||||
uint32_t mSizeOfGrps;
|
uint32_t mSizeOfGrps;
|
||||||
uint32_t mNumGrpsSubscribed;
|
uint32_t mNumGrpsSubscribed;
|
||||||
uint32_t mNumMsgsNew;
|
uint32_t mNumThreadMsgsNew;
|
||||||
uint32_t mNumMsgsUnread;
|
uint32_t mNumThreadMsgsUnread;
|
||||||
|
uint32_t mNumChildMsgsNew;
|
||||||
|
uint32_t mNumChildMsgsUnread;
|
||||||
uint32_t mSizeStore;
|
uint32_t mSizeStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
mInitialized = false;
|
mInitialized = false;
|
||||||
|
mCountChildMsgs = false;
|
||||||
mYourGroups = NULL;
|
mYourGroups = NULL;
|
||||||
mSubscribedGroups = NULL;
|
mSubscribedGroups = NULL;
|
||||||
mPopularGroups = NULL;
|
mPopularGroups = NULL;
|
||||||
@ -897,7 +898,7 @@ void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->groupTreeWidget->setUnreadCount(item, stats.mNumMsgsUnread);
|
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
@ -169,6 +169,9 @@ private:
|
|||||||
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
|
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
|
||||||
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool mCountChildMsgs; // Count unread child messages?
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
QString mSettingsName;
|
QString mSettingsName;
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||||
UserNotify(parent), TokenResponse()
|
UserNotify(parent), TokenResponse()
|
||||||
{
|
{
|
||||||
mNewMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
|
mNewChildMessageCount = 0;
|
||||||
|
mCountChildMsgs = false;
|
||||||
|
|
||||||
mInterface = ifaceImpl;
|
mInterface = ifaceImpl;
|
||||||
mTokenService = mInterface->getTokenService();
|
mTokenService = mInterface->getTokenService();
|
||||||
@ -51,7 +53,8 @@ GxsUserNotify::~GxsUserNotify()
|
|||||||
|
|
||||||
void GxsUserNotify::startUpdate()
|
void GxsUserNotify::startUpdate()
|
||||||
{
|
{
|
||||||
mNewMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
|
mNewChildMessageCount = 0;
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mTokenService->requestServiceStatistic(token);
|
mTokenService->requestServiceStatistic(token);
|
||||||
@ -68,7 +71,8 @@ void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req
|
|||||||
GxsServiceStatistic stats;
|
GxsServiceStatistic stats;
|
||||||
mInterface->getServiceStatistic(req.mToken, stats);
|
mInterface->getServiceStatistic(req.mToken, stats);
|
||||||
|
|
||||||
mNewMessageCount = stats.mNumMsgsNew;
|
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
||||||
|
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,18 @@ protected:
|
|||||||
virtual void startUpdate();
|
virtual void startUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual unsigned int getNewCount() { return mNewMessageCount; }
|
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool mCountChildMsgs; // Count new child messages?
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsIfaceHelper *mInterface;
|
RsGxsIfaceHelper *mInterface;
|
||||||
RsTokenService *mTokenService;
|
RsTokenService *mTokenService;
|
||||||
TokenQueue *mTokenQueue;
|
TokenQueue *mTokenQueue;
|
||||||
RsGxsUpdateBroadcastBase *mBase;
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
unsigned int mNewMessageCount;
|
unsigned int mNewThreadMessageCount;
|
||||||
|
unsigned int mNewChildMessageCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GXSUSERNOTIFY_H
|
#endif // GXSUSERNOTIFY_H
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, parent)
|
||||||
{
|
{
|
||||||
|
mCountChildMsgs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
|
bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||||
: GxsGroupFrameDialog(rsGxsForums, parent)
|
: GxsGroupFrameDialog(rsGxsForums, parent)
|
||||||
{
|
{
|
||||||
|
mCountChildMsgs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsForumsDialog::~GxsForumsDialog()
|
GxsForumsDialog::~GxsForumsDialog()
|
||||||
|
Loading…
Reference in New Issue
Block a user