Fix Forum Mark All As Read.

Now only mark changed post to reduce DB access.
This commit is contained in:
Phenom 2020-04-14 14:32:53 +02:00
parent b6c5e2f188
commit 69a0fa64da

View file

@ -1226,13 +1226,17 @@ void RsGxsForumModel::setMsgReadStatus(const QModelIndex& i,bool read_status,boo
void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,bool with_children) void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,bool with_children)
{ {
if(read_status) int newStatus = (read_status ? mPosts[i].mMsgStatus & ~static_cast<int>(GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD)
mPosts[i].mMsgStatus = 0; : mPosts[i].mMsgStatus | static_cast<int>(GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD));
else bool bChanged = (mPosts[i].mMsgStatus != newStatus);
mPosts[i].mMsgStatus = GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; mPosts[i].mMsgStatus = newStatus;
//Remove Unprocessed and New flags
mPosts[i].mMsgStatus &= ~(GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW);
if (bChanged)
{
//Don't recurs post versions as this should be done before, if no change.
uint32_t token; uint32_t token;
auto s = getPostVersions(mPosts[i].mMsgId) ; auto s = getPostVersions(mPosts[i].mMsgId) ;
if(!s.empty()) if(!s.empty())
@ -1243,6 +1247,7 @@ void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,
} }
else else
rsGxsForums->setMessageReadStatus(token,std::make_pair( mForumGroup.mMeta.mGroupId, mPosts[i].mMsgId ), read_status); rsGxsForums->setMessageReadStatus(token,std::make_pair( mForumGroup.mMeta.mGroupId, mPosts[i].mMsgId ), read_status);
}
if(!with_children) if(!with_children)
return; return;