diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 8c9a882b6..507562840 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -52,7 +52,11 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this); headerFrame->setHeaderImage(QPixmap(":/images/channels.png")); - headerFrame->setHeaderText(tr("New Channel Post")); + + if(!existing_post.isNull()) + headerFrame->setHeaderText(tr("Edit Channel Post")); + else + headerFrame->setHeaderText(tr("New Channel Post")); setAttribute ( Qt::WA_DeleteOnClose, true ); @@ -639,6 +643,7 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str post.mMeta.mThreadId.clear() ; post.mMeta.mMsgId.clear() ; + post.mMeta.mOrigMsgId = mOrigPostId; post.mMeta.mMsgName = subject; post.mMsg = msg; post.mFiles = files; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 6e8170ef1..7e2b6a9b5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -451,14 +451,22 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector &po std::vector new_versions ; for (uint32_t i=0;i search_map ; @@ -467,37 +475,60 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector &po for(uint32_t i=0;i versions ; + std::map::const_iterator vit ; + + while(search_map.end() != (vit=search_map.find(posts[current_index].mMeta.mOrigMsgId))) { - std::map::const_iterator vit = search_map.find(posts[new_versions[i]].mMeta.mOrigMsgId) ; + std::cerr << " post at index " << current_index << " replaces a post at position " << vit->second ; - if(vit == search_map.end()) // original post not found. Give up. + // Now replace the post only if the new versionis more recent. It may happen indeed that the same post has been corrected multiple + // times. In this case, we only need to replace the post with the newest version + + uint32_t prev_index = current_index ; + current_index = vit->second ; + + if(posts[current_index].mMeta.mMsgId.isNull()) // This handles the branching situation where this post has been already erased. No need to go down further. + { + std::cerr << " already erased. Stopping." << std::endl; break ; + } - posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored - current_index = vit->second ; + if(posts[current_index].mMeta.mPublishTs < posts[source_index].mMeta.mPublishTs) + { + std::cerr << " and is more recent => following" << std::endl; + + posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored + } + else + std::cerr << " but is older -> Stopping" << std::endl; } - - 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 ; +// posts[current_index] = posts[source_index] ;// copy all the data of the source post into the oldest post version (this is to keep the placement of the post in the list) +// posts[current_index].mMeta.mOrigMsgId.clear(); +// posts[current_index].mMeta.mMsgId = source_msg_id; } } + std::cerr << "Now adding posts..." << std::endl; + for (std::vector::const_reverse_iterator it = posts.rbegin(); it != posts.rend(); ++it) - if((*it).mMeta.mMsgId.isNull()) + { + std::cerr << " adding post: " << (*it).mMeta.mMsgId ; + + if(!(*it).mMeta.mMsgId.isNull()) { + std::cerr << " added" << std::endl; + if (thread && thread->stopped()) break; @@ -506,6 +537,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector &po else createPostItem(*it, related); } + else + std::cerr << " skipped" << std::endl; + } if (!thread) { ui->feedWidget->setSortingEnabled(true);