merge comments between channel item versions

This commit is contained in:
csoler 2017-05-20 17:33:05 +02:00
parent 6b09fa0f67
commit 51710c10a0
6 changed files with 32 additions and 4 deletions

View File

@ -60,6 +60,8 @@ public:
public:
RsMsgMetaData mMeta;
std::set<RsGxsMessageId> mOlderVersions ;
std::string mMsg; // UTF8 encoded.
std::list<RsGxsFile> mFiles;

View File

@ -64,6 +64,21 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId,
std::cerr << std::endl;
#endif
QVector<RsGxsMessageId> v;
bool self = false;
for(std::set<RsGxsMessageId>::const_iterator it(post.mOlderVersions.begin());it!=post.mOlderVersions.end();++it)
{
if(*it == post.mMeta.mMsgId)
self = true ;
v.push_back(*it) ;
}
if(!self)
v.push_back(post.mMeta.mMsgId);
setMessageVersions(v) ;
setup();
//setGroup(group, false);

View File

@ -64,7 +64,10 @@ void GxsFeedItem::comments(const QString &title)
if (mFeedHolder)
{
mFeedHolder->openComments(feedId(), groupId(), messageId(), title);
if(mMessageVersions.empty())
mFeedHolder->openComments(feedId(), groupId(),QVector<RsGxsMessageId>(1,messageId()), messageId(), title);
else
mFeedHolder->openComments(feedId(), groupId(),mMessageVersions, messageId(), title);
}
}

View File

@ -35,9 +35,12 @@ public:
GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate);
virtual ~GxsFeedItem();
RsGxsMessageId messageId() { return mMessageId; }
RsGxsMessageId messageId() const { return mMessageId; }
const QVector<RsGxsMessageId>& messageVersions() const { return mMessageVersions ; }
//To be able to update with thread message when comment is received.
void setMessageId( RsGxsMessageId id) {mMessageId = id;}
void setMessageVersions( const QVector<RsGxsMessageId>& v) { mMessageVersions = v;}
protected:
/* load message data */
@ -61,6 +64,7 @@ protected slots:
private:
RsGxsMessageId mMessageId;
QVector<RsGxsMessageId> mMessageVersions ;
uint32_t mTokenTypeMessage;
uint32_t mTokenTypeComment;
};

View File

@ -45,8 +45,8 @@ public:
GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool autoUpdate);
virtual ~GxsGroupFeedItem();
RsGxsGroupId groupId() { return mGroupId; }
uint32_t feedId() { return mFeedId; }
RsGxsGroupId groupId() const { return mGroupId; }
uint32_t feedId() const { return mFeedId; }
protected:
uint32_t nextTokenType() { return ++mNextTokenType; }

View File

@ -543,6 +543,10 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
#ifdef DEBUG_CHANNEL
std::cerr << " and is more recent => following" << std::endl;
#endif
for(std::set<RsGxsMessageId>::const_iterator itt(posts[current_index].mOlderVersions.begin());itt!=posts[current_index].mOlderVersions.end();++itt)
posts[source_index].mOlderVersions.insert(*itt);
posts[source_index].mOlderVersions.insert(posts[current_index].mMeta.mMsgId);
posts[current_index].mMeta.mMsgId.clear(); // clear the msg Id so the post will be ignored
}
#ifdef DEBUG_CHANNEL