fixed update of comment/unread comment count when a new version of a msg arrives

This commit is contained in:
csoler 2023-03-24 13:48:48 +01:00
parent dec1d3068b
commit e4910cf8fd
2 changed files with 13 additions and 2 deletions

View File

@ -498,7 +498,14 @@ void RsGxsChannelPostsModel::updateSinglePost(const RsGxsChannelPost& post,std::
added_files.insert(post.mFiles.begin(),post.mFiles.end());
removed_files.insert(mPosts[j].mFiles.begin(),mPosts[j].mFiles.end());
auto save_ucc = mPosts[j].mUnreadCommentCount;
auto save_cc = mPosts[j].mCommentCount;
mPosts[j] = post;
mPosts[j].mUnreadCommentCount = save_ucc;
mPosts[j].mCommentCount = save_cc;
#ifdef DEBUG_CHANNEL_MODEL
RsDbg() << " post is an updated existing post." ;
#endif
@ -512,7 +519,13 @@ void RsGxsChannelPostsModel::updateSinglePost(const RsGxsChannelPost& post,std::
removed_files.insert(mPosts[j].mFiles.begin(),mPosts[j].mFiles.end());
auto old_post_id = mPosts[j].mMeta.mMsgId;
auto save_ucc = mPosts[j].mUnreadCommentCount;
auto save_cc = mPosts[j].mCommentCount;
mPosts[j] = post;
mPosts[j].mCommentCount += save_cc;
mPosts[j].mUnreadCommentCount += save_ucc;
mPosts[j].mOlderVersions.insert(old_post_id);
#ifdef DEBUG_CHANNEL_MODEL
RsDbg() << " post is an new version of an existing post." ;

View File

@ -805,7 +805,6 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<con
return;
}
#ifdef TO_REMOVE
// Need to call this in order to get the actual comment count. The previous call only retrieves the message, since we supplied the message ID.
// another way to go would be to save the comment ids of the existing message and re-insert them before calling getChannelContent.
@ -818,7 +817,6 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<con
// Normally, there's a single post in the "post" array. The function below takes a full array of posts however.
RsGxsChannelPostsModel::computeCommentCounts(posts,comments);
#endif
// 2 - update the model in the UI thread.