diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 9610fc1a6..99725cd70 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -2717,10 +2717,15 @@ void RsGenExchange::processMessageDelete() msgDeleted.push_back(note.msgIds); } - for(const auto& msgreq:msgDeleted) - for(const auto& msgit:msgreq) - for(const auto& msg:msgit.second) - mNotifications.push_back(new RsGxsMsgChange(RsGxsNotify::TYPE_MESSAGE_DELETED,msgit.first,msg, false)); + /* Three nested for looks like a performance bomb, but as Cyril says here + * https://github.com/RetroShare/RetroShare/pull/2218#pullrequestreview-565194022 + * this should actually not explode at all because it is just one message at + * time that get notified */ + for(const auto& msd : mMsgDeletePublish) + for(auto& msgMap : msd.mMsgs) + for(auto& msgId : msgMap.second) + mNotifications.push_back( + new RsGxsMsgDeletedChange(msgMap.first, msgId) ); mMsgDeletePublish.clear(); } diff --git a/libretroshare/src/gxs/rsgxsnotify.h b/libretroshare/src/gxs/rsgxsnotify.h index 6f186e1fe..030d9f26f 100644 --- a/libretroshare/src/gxs/rsgxsnotify.h +++ b/libretroshare/src/gxs/rsgxsnotify.h @@ -97,13 +97,13 @@ private: bool mMetaChange; }; -struct RsGxsBulkMsgDeletedChange : RsGxsNotify +struct RsGxsMsgDeletedChange : RsGxsNotify { - RsGxsBulkMsgDeletedChange( - const RsGxsGroupId& gid, const std::set& msgsId): - RsGxsNotify(gid), messagesId(msgsId) {} + RsGxsMsgDeletedChange( + const RsGxsGroupId& gid, const RsGxsMessageId& msgId): + RsGxsNotify(gid), messageId(msgId) {} NotifyType getType() override { return TYPE_MESSAGE_DELETED; } - const std::set messagesId; + const RsGxsMessageId messageId; }; diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index 182a8177d..1b35f2db9 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -118,7 +118,7 @@ enum class RsForumEventCode: uint8_t SYNC_PARAMETERS_UPDATED = 0x0a, /// sync and storage times have changed PINNED_POSTS_CHANGED = 0x0b, /// some posts where pinned or un-pinned DELETED_FORUM = 0x0c, /// forum was deleted by cleaning - DELETED_POSTS = 13 /// Posts deleted by cleaning + DELETED_POSTS = 0x0d /// Posts deleted by cleaning }; struct RsGxsForumEvent: RsEvent @@ -129,9 +129,9 @@ struct RsGxsForumEvent: RsEvent RsForumEventCode mForumEventCode; RsGxsGroupId mForumGroupId; - std::set mForumMsgsId; - std::list mModeratorsAdded; - std::list mModeratorsRemoved; + RsGxsMessageId mForumMsgId; + std::list mModeratorsAdded; + std::list mModeratorsRemoved; ///* @see RsEvent @see RsSerializable void serial_process( @@ -141,7 +141,7 @@ struct RsGxsForumEvent: RsEvent RsEvent::serial_process(j, ctx); RS_SERIAL_PROCESS(mForumEventCode); RS_SERIAL_PROCESS(mForumGroupId); - RS_SERIAL_PROCESS(mForumMsgsId); + RS_SERIAL_PROCESS(mForumMsgId); RS_SERIAL_PROCESS(mModeratorsAdded); RS_SERIAL_PROCESS(mModeratorsRemoved); } diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index b8d2194c5..a57d4e68f 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -211,7 +211,7 @@ void p3GxsForums::notifyChanges(std::vector &changes) if(msgChange) /* Message received*/ { auto ev = std::make_shared(); - ev->mForumMsgsId.insert(msgChange->mMsgId); + ev->mForumMsgId = msgChange->mMsgId; ev->mForumGroupId = msgChange->mGroupId; ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE; rsEvents->postEvent(ev); @@ -258,8 +258,8 @@ void p3GxsForums::notifyChanges(std::vector &changes) } case RsGxsNotify::TYPE_MESSAGE_DELETED: { - rs_view_ptr delChange = - dynamic_cast(gxsChange); + rs_view_ptr delChange = + dynamic_cast(gxsChange); if(!delChange) { @@ -272,7 +272,7 @@ void p3GxsForums::notifyChanges(std::vector &changes) auto ev = std::make_shared(); ev->mForumEventCode = RsForumEventCode::DELETED_POSTS; ev->mForumGroupId = delChange->mGroupId; - ev->mForumMsgsId = delChange->messagesId; + ev->mForumMsgId = delChange->messageId; break; } case RsGxsNotify::TYPE_GROUP_DELETED: @@ -1053,7 +1053,7 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& { auto ev = std::make_shared(); - ev->mForumMsgsId.insert(msgId.second); + ev->mForumMsgId = msgId.second; ev->mForumGroupId = msgId.first; ev->mForumEventCode = RsForumEventCode::READ_STATUS_CHANGED; rsEvents->postEvent(ev); @@ -1084,7 +1084,7 @@ std::error_condition p3GxsForums::setPostKeepForever( { auto ev = std::make_shared(); ev->mForumGroupId = forumId; - ev->mForumMsgsId.insert(postId); + ev->mForumMsgId = postId; ev->mForumEventCode = RsForumEventCode::UPDATED_MESSAGE; rsEvents->postEvent(ev); return std::error_condition(); diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 3c86de318..4e59685b3 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -270,9 +270,9 @@ void NewsFeed::handleForumEvent(std::shared_ptr event) case RsForumEventCode::UPDATED_MESSAGE: case RsForumEventCode::NEW_MESSAGE: - for(const auto& postId: pe->mForumMsgsId) addFeedItem(new GxsForumMsgItem( - this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, postId, + this, NEWSFEED_NEW_FORUM, + pe->mForumGroupId, pe->mForumMsgId, false, true )); break;