From e4910cf8fdd9ee43f78a1cb97b91bbf6fea83cea Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 24 Mar 2023 13:48:48 +0100 Subject: [PATCH] fixed update of comment/unread comment count when a new version of a msg arrives --- .../src/gui/gxschannels/GxsChannelPostsModel.cpp | 13 +++++++++++++ .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 508db7046..865cd776b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -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." ; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index ed721a66a..e63b96633 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -805,7 +805,6 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr