mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 21:29:23 -04:00
added ifdefs around debug info and fixed a few bugs in channel post edit
This commit is contained in:
parent
6859e0d8ca
commit
01bb4b09a9
2 changed files with 34 additions and 5 deletions
|
@ -66,7 +66,8 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
setGroup(group, false);
|
//setGroup(group, false);
|
||||||
|
requestGroup();
|
||||||
setPost(post);
|
setPost(post);
|
||||||
requestComment();
|
requestComment();
|
||||||
}
|
}
|
||||||
|
@ -168,6 +169,12 @@ bool GxsChannelPostItem::setGroup(const RsGxsChannelGroup &group, bool doFill)
|
||||||
|
|
||||||
mGroup = group;
|
mGroup = group;
|
||||||
|
|
||||||
|
// if not publisher, hide the edit button. Without the publish key, there's no way to edit a message.
|
||||||
|
|
||||||
|
std::cerr << "Group subscribe flags = " << std::hex << mGroup.mMeta.mSubscribeFlags << std::dec << std::endl;
|
||||||
|
if(!IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
|
||||||
|
ui->editButton->hide();
|
||||||
|
|
||||||
if (doFill) {
|
if (doFill) {
|
||||||
fill();
|
fill();
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,7 +447,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
|
|
||||||
// collect new versions of posts if any
|
// collect new versions of posts if any
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << "Inserting channel posts" << std::endl;
|
std::cerr << "Inserting channel posts" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<uint32_t> new_versions ;
|
std::vector<uint32_t> new_versions ;
|
||||||
for (uint32_t i=0;i<posts.size();++i)
|
for (uint32_t i=0;i<posts.size();++i)
|
||||||
|
@ -455,18 +457,24 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
if(posts[i].mMeta.mOrigMsgId == posts[i].mMeta.mMsgId)
|
if(posts[i].mMeta.mOrigMsgId == posts[i].mMeta.mMsgId)
|
||||||
posts[i].mMeta.mOrigMsgId.clear();
|
posts[i].mMeta.mOrigMsgId.clear();
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " " << i << ": msg_id=" << posts[i].mMeta.mMsgId << ": orig msg id = " << posts[i].mMeta.mOrigMsgId << std::endl;
|
std::cerr << " " << i << ": msg_id=" << posts[i].mMeta.mMsgId << ": orig msg id = " << posts[i].mMeta.mOrigMsgId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!posts[i].mMeta.mOrigMsgId.isNull())
|
if(!posts[i].mMeta.mOrigMsgId.isNull())
|
||||||
new_versions.push_back(i) ;
|
new_versions.push_back(i) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << "New versions: " << new_versions.size() << std::endl;
|
std::cerr << "New versions: " << new_versions.size() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!new_versions.empty())
|
if(!new_versions.empty())
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " New versions present. Replacing them..." << std::endl;
|
std::cerr << " New versions present. Replacing them..." << std::endl;
|
||||||
std::cerr << " Creating search map." << std::endl;
|
std::cerr << " Creating search map." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// make a quick search map
|
// make a quick search map
|
||||||
std::map<RsGxsMessageId,uint32_t> search_map ;
|
std::map<RsGxsMessageId,uint32_t> search_map ;
|
||||||
|
@ -475,7 +483,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
|
|
||||||
for(uint32_t i=0;i<new_versions.size();++i)
|
for(uint32_t i=0;i<new_versions.size();++i)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " Taking care of new version at index " << new_versions[i] << std::endl;
|
std::cerr << " Taking care of new version at index " << new_versions[i] << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t current_index = new_versions[i] ;
|
uint32_t current_index = new_versions[i] ;
|
||||||
uint32_t source_index = new_versions[i] ;
|
uint32_t source_index = new_versions[i] ;
|
||||||
|
@ -490,7 +500,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
|
|
||||||
while(search_map.end() != (vit=search_map.find(posts[current_index].mMeta.mOrigMsgId)))
|
while(search_map.end() != (vit=search_map.find(posts[current_index].mMeta.mOrigMsgId)))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " post at index " << current_index << " replaces a post at position " << vit->second ;
|
std::cerr << " post at index " << current_index << " replaces a post at position " << vit->second ;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Now replace the post only if the new versionis more recent. It may happen indeed that the same post has been corrected multiple
|
// 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
|
// times. In this case, we only need to replace the post with the newest version
|
||||||
|
@ -500,34 +512,42 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
|
|
||||||
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.
|
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.
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " already erased. Stopping." << std::endl;
|
std::cerr << " already erased. Stopping." << std::endl;
|
||||||
|
#endif
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(posts[current_index].mMeta.mPublishTs < posts[source_index].mMeta.mPublishTs)
|
if(posts[current_index].mMeta.mPublishTs < posts[source_index].mMeta.mPublishTs)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " and is more recent => following" << std::endl;
|
std::cerr << " and is more recent => following" << std::endl;
|
||||||
|
#endif
|
||||||
posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored
|
posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
else
|
else
|
||||||
std::cerr << " but is older -> Stopping" << std::endl;
|
std::cerr << " but is older -> Stopping" << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << "Now adding posts..." << std::endl;
|
std::cerr << "Now adding posts..." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (std::vector<RsGxsChannelPost>::const_reverse_iterator it = posts.rbegin(); it != posts.rend(); ++it)
|
for (std::vector<RsGxsChannelPost>::const_reverse_iterator it = posts.rbegin(); it != posts.rend(); ++it)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " adding post: " << (*it).mMeta.mMsgId ;
|
std::cerr << " adding post: " << (*it).mMeta.mMsgId ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!(*it).mMeta.mMsgId.isNull())
|
if(!(*it).mMeta.mMsgId.isNull())
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
std::cerr << " added" << std::endl;
|
std::cerr << " added" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (thread && thread->stopped())
|
if (thread && thread->stopped())
|
||||||
break;
|
break;
|
||||||
|
@ -537,8 +557,10 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
else
|
else
|
||||||
createPostItem(*it, related);
|
createPostItem(*it, related);
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_CHANNEL
|
||||||
else
|
else
|
||||||
std::cerr << " skipped" << std::endl;
|
std::cerr << " skipped" << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue