mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -04:00
clear comments when switching channels
This commit is contained in:
parent
d472053960
commit
0a6e15c524
4 changed files with 13 additions and 9 deletions
|
@ -76,24 +76,18 @@ void updateCommentCounts( std::vector<RsGxsChannelPost>& posts, std::vector<RsGx
|
|||
{
|
||||
// Store posts IDs in a std::map to avoid a quadratic cost
|
||||
|
||||
std::cerr << "Updating comment counts for " << posts.size() << " posts." << std::endl;
|
||||
std::map<RsGxsMessageId,uint32_t> post_indices;
|
||||
|
||||
for(uint32_t i=0;i<posts.size();++i)
|
||||
{
|
||||
post_indices[posts[i].mMeta.mMsgId] = i;
|
||||
posts[i].mCommentCount = 0; // should be 0 already, but we secure that value.
|
||||
|
||||
std::cerr << " Zeroing comments for post " << posts[i].mMeta.mMsgId << std::endl;
|
||||
}
|
||||
|
||||
// now look into comments and increase the count
|
||||
|
||||
for(uint32_t i=0;i<comments.size();++i)
|
||||
{
|
||||
std::cerr << " Found new comment " << comments[i].mMeta.mMsgId << " for post" << comments[i].mMeta.mThreadId << std::endl;
|
||||
++posts[post_indices[comments[i].mMeta.mThreadId]].mCommentCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +122,9 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
|
|||
return;
|
||||
}
|
||||
|
||||
// Need to call this in order to get the actuall comment count. The previous call only retrieves the message, since we supplied the message ID.
|
||||
// another way to go would be to save the comment ids of the existing message and re-insert them before calling getChannelContent.
|
||||
|
||||
if(!rsGxsChannels->getChannelComments(mChannelGroup.mMeta.mGroupId,std::set<RsGxsMessageId>{ e->mChannelMsgId },comments))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve message comment data for channel/msg " << e->mChannelGroupId << "/" << e->mChannelMsgId << std::endl;
|
||||
|
@ -228,8 +225,6 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unre
|
|||
|
||||
count = mFilteredPosts.size();
|
||||
|
||||
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||
|
||||
beginInsertRows(QModelIndex(),0,rowCount()-1);
|
||||
endInsertRows();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue