diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 76c777607..6e8170ef1 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -438,8 +438,6 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector &po return; } - std::vector::const_reverse_iterator it; - int count = posts.size(); int pos = 0; @@ -447,18 +445,67 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector &po ui->feedWidget->setSortingEnabled(false); } - for (it = posts.rbegin(); it != posts.rend(); ++it) - { - if (thread && thread->stopped()) { - break; - } + // collect new versions of posts if any - if (thread) { - thread->emitAddPost(qVariantFromValue(*it), related, ++pos, count); - } else { - createPostItem(*it, related); + std::cerr << "Inserting channel posts" << std::endl; + + std::vector new_versions ; + for (uint32_t i=0;i search_map ; + for (uint32_t i=0;i::const_iterator vit = search_map.find(posts[new_versions[i]].mMeta.mOrigMsgId) ; + + if(vit == search_map.end()) // original post not found. Give up. + break ; + + posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored + current_index = vit->second ; + } + + RsGxsMessageId orig_msg_id = posts[current_index].mMeta.mMsgId ; // save these two + RsGxsMessageId orig_orig_id = posts[current_index].mMeta.mOrigMsgId ; + + std::cerr << " new version of post " << orig_msg_id << " is " << posts[source_index].mMeta.mMsgId << " at position " << current_index << std::endl; + + posts[current_index] = posts[source_index] ; // copy all the data to the parent (this is to keep the placement of the post in the list) + + posts[current_index].mMeta.mMsgId = orig_msg_id ; + posts[current_index].mMeta.mOrigMsgId = orig_orig_id ; + } + } + + for (std::vector::const_reverse_iterator it = posts.rbegin(); it != posts.rend(); ++it) + if((*it).mMeta.mMsgId.isNull()) + { + if (thread && thread->stopped()) + break; + + if (thread) + thread->emitAddPost(qVariantFromValue(*it), related, ++pos, count); + else + createPostItem(*it, related); } - } if (!thread) { ui->feedWidget->setSortingEnabled(true);