From 08e298715405ceae652575fee36d56ea4e67580d Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 7 Nov 2020 20:52:50 +0100 Subject: [PATCH] added icon over posts with comments in channels --- libretroshare/src/retroshare/rsgxschannels.h | 4 +-- .../gui/Posted/PostedListWidgetWithModel.cpp | 4 ++- .../gui/gxschannels/GxsChannelPostsModel.cpp | 28 +++++++++++++++++++ .../GxsChannelPostsWidgetWithModel.cpp | 19 +++++++++++-- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 975498728..d9bf6c7a7 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -71,14 +71,14 @@ struct RsGxsChannelGroup : RsSerializable, RsGxsGenericGroupData struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData { - RsGxsChannelPost() : mAttachmentCount(0), mSize(0) {} + RsGxsChannelPost() : mAttachmentCount(0), mCommentCount(0), mSize(0) {} std::set mOlderVersions; std::string mMsg; // UTF8 encoded. std::list mFiles; uint32_t mAttachmentCount; // auto calced. - uint32_t mCommentCount; // auto calced. + uint32_t mCommentCount; // auto calced. WARNING: not computed yet. In the future we need a background process to update this and store in the service string. uint64_t mSize; // auto calced. RsGxsImage mThumbnail; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 845e48783..eb1fe9bae 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -474,7 +474,8 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptrmPostedEventCode) { - case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; + case RsPostedEventCode::NEW_COMMENT: // [[fallthrough]]; + case RsPostedEventCode::NEW_VOTE: // [[fallthrough]]; { // special treatment here because the message might be a comment, so we need to refresh the comment tab if openned @@ -486,6 +487,7 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptrrefresh(); } } + case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; case RsPostedEventCode::UPDATED_POSTED_GROUP: // [[fallthrough]]; case RsPostedEventCode::UPDATED_MESSAGE: diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index a5a56597b..d65689766 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -522,6 +522,29 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto emit channelPostsLoaded(); } +static void updateCommentCounts( std::vector& posts, std::vector& comments) +{ + // Store posts IDs in a std::map to avoid a quadratic cost + + std::map post_indices; + + for(uint32_t i=0;i