mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
Merge pull request #2220 from csoler/v0.6-BugFixing_5
Bug fixing for 0.6.6
This commit is contained in:
commit
8bfdbe6af8
@ -71,14 +71,15 @@ struct RsGxsChannelGroup : RsSerializable, RsGxsGenericGroupData
|
||||
|
||||
struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData
|
||||
{
|
||||
RsGxsChannelPost() : mAttachmentCount(0), mCommentCount(0), mSize(0) {}
|
||||
RsGxsChannelPost() : mAttachmentCount(0), mCommentCount(0), mUnreadCommentCount(0), mSize(0) {}
|
||||
|
||||
std::set<RsGxsMessageId> mOlderVersions;
|
||||
std::string mMsg; // UTF8 encoded.
|
||||
|
||||
std::list<RsGxsFile> mFiles;
|
||||
uint32_t mAttachmentCount; // auto calced.
|
||||
uint32_t mCommentCount; // auto calced. WARNING: not computed yet. In the future we need a background process to update this and store in the service string.
|
||||
uint32_t mCommentCount; // auto calced.
|
||||
uint32_t mUnreadCommentCount; // auto calced.
|
||||
uint64_t mSize; // auto calced.
|
||||
|
||||
RsGxsImage mThumbnail;
|
||||
@ -95,6 +96,7 @@ struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData
|
||||
RS_SERIAL_PROCESS(mFiles);
|
||||
RS_SERIAL_PROCESS(mAttachmentCount);
|
||||
RS_SERIAL_PROCESS(mCommentCount);
|
||||
RS_SERIAL_PROCESS(mUnreadCommentCount);
|
||||
RS_SERIAL_PROCESS(mSize);
|
||||
RS_SERIAL_PROCESS(mThumbnail);
|
||||
}
|
||||
|
@ -176,6 +176,8 @@ struct RsGxsCommentService
|
||||
virtual bool acknowledgeVote(
|
||||
uint32_t token,
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) = 0;
|
||||
|
||||
virtual bool setCommentAsRead(uint32_t& token,const RsGxsGroupId& gid,const RsGxsMessageId& comment_msg_id) = 0;
|
||||
};
|
||||
|
||||
/// @deprecated use RsGxsVoteType::NONE instead @see RsGxsVoteType
|
||||
|
@ -202,7 +202,9 @@ public:
|
||||
virtual bool getPostData(
|
||||
const uint32_t& token, std::vector<RsPostedPost>& posts) = 0;
|
||||
|
||||
//Not currently used
|
||||
virtual bool setCommentAsRead(uint32_t& token,const RsGxsGroupId& gid,const RsGxsMessageId& comment_msg_id) =0;
|
||||
|
||||
//Not currently used
|
||||
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
|
||||
|
||||
/* From RsGxsCommentService */
|
||||
|
@ -151,6 +151,12 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
|
||||
return mCommentService->createGxsComment(token, msg);
|
||||
}
|
||||
|
||||
virtual bool setCommentAsRead(uint32_t& token,const RsGxsGroupId& gid,const RsGxsMessageId& comment_msg_id) override
|
||||
{
|
||||
setMessageReadStatus(token,RsGxsGrpMsgIdPair(gid,comment_msg_id),true);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool createNewVote(uint32_t &token, RsGxsVote &msg) override
|
||||
{
|
||||
return mCommentService->createGxsVote(token, msg);
|
||||
|
@ -110,6 +110,13 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
|
||||
return p3PostBase::setMessageReadStatus(token, msgId, read);
|
||||
}
|
||||
|
||||
virtual bool setCommentAsRead(uint32_t& token,const RsGxsGroupId& gid,const RsGxsMessageId& comment_msg_id) override
|
||||
{
|
||||
p3PostBase::setMessageReadStatus(token,RsGxsGrpMsgIdPair(gid,comment_msg_id),true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Comment service - Provide RsGxsCommentService -
|
||||
* redirect to p3GxsCommentService */
|
||||
|
@ -659,8 +659,10 @@ void GenCertDialog::genPerson()
|
||||
RsInit::LoadPassword(sslPasswd);
|
||||
if (Rshare::loadCertificate(sslId, false)) {
|
||||
|
||||
// Now clear the cached passphrase
|
||||
rsNotify->clearPgpPassphrase();
|
||||
// Normally we should clear the cached passphrase as soon as possible. However,some other GUI components may still need it at start.
|
||||
// (csoler) This is really bad: we have to guess that 30 secs will be enough. I have no better way to do this.
|
||||
|
||||
QTimer::singleShot(30000, []() { rsNotify->clearPgpPassphrase(); } );
|
||||
|
||||
accept();
|
||||
}
|
||||
|
@ -753,9 +753,15 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
|
||||
|
||||
void GxsCommentTreeWidget::insertComments(const std::vector<RsGxsComment>& comments)
|
||||
{
|
||||
std::list<RsGxsMessageId> new_comments;
|
||||
|
||||
for(auto vit = comments.begin(); vit != comments.end(); ++vit)
|
||||
{
|
||||
const RsGxsComment &comment = *vit;
|
||||
|
||||
if(IS_MSG_NEW(comment.mMeta.mMsgStatus))
|
||||
new_comments.push_back(comment.mMeta.mMsgId);
|
||||
|
||||
/* convert to a QTreeWidgetItem */
|
||||
std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
@ -811,6 +817,14 @@ void GxsCommentTreeWidget::insertComments(const std::vector<RsGxsComment>& comme
|
||||
|
||||
addItem(comment.mMeta.mMsgId, comment.mMeta.mParentId, item);
|
||||
}
|
||||
|
||||
// now set all loaded comments as not new, since they have been loaded.
|
||||
|
||||
for(auto cid:new_comments)
|
||||
{
|
||||
uint32_t token=0;
|
||||
mCommentService->setCommentAsRead(token,mGroupId,cid);
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMessageId& parent)
|
||||
|
@ -57,6 +57,7 @@ protected:
|
||||
/* to be overloaded */
|
||||
virtual void service_requestComments(const RsGxsGroupId &group_id, const std::set<RsGxsMessageId> &msgIds);
|
||||
virtual void service_loadThread(const uint32_t &token);
|
||||
|
||||
virtual QTreeWidgetItem *service_createMissingItem(const RsGxsMessageId& parent);
|
||||
|
||||
void clearItems();
|
||||
|
@ -82,6 +82,7 @@ void updateCommentCounts( std::vector<RsGxsChannelPost>& posts, std::vector<RsGx
|
||||
{
|
||||
post_indices[posts[i].mMeta.mMsgId] = i;
|
||||
posts[i].mCommentCount = 0; // should be 0 already, but we secure that value.
|
||||
posts[i].mUnreadCommentCount = 0;
|
||||
}
|
||||
|
||||
// now look into comments and increase the count
|
||||
@ -100,6 +101,9 @@ void updateCommentCounts( std::vector<RsGxsChannelPost>& posts, std::vector<RsGx
|
||||
continue;
|
||||
|
||||
++posts[it->second].mCommentCount;
|
||||
|
||||
if(IS_MSG_NEW(comments[i].mMeta.mMsgStatus))
|
||||
++posts[it->second].mUnreadCommentCount;
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,21 +133,42 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
|
||||
RsThread::async([this, E]()
|
||||
{
|
||||
// 1 - get message data from p3GxsChannels. No need for pointers here, because we send only a single post to postToObject()
|
||||
// At this point we dont know what kind of msg id we have. It can be a vote, a comment or an actual message.
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
std::vector<RsGxsVote> votes;
|
||||
std::set<RsGxsMessageId> msg_ids{ E.mChannelMsgId };
|
||||
|
||||
if(!rsGxsChannels->getChannelContent(E.mChannelGroupId,std::set<RsGxsMessageId>{ E.mChannelMsgId }, posts,comments,votes))
|
||||
if(!rsGxsChannels->getChannelContent(E.mChannelGroupId,msg_ids, posts,comments,votes))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if what we have actually is a comment or a vote. If so we need to update the actual message they refer to
|
||||
|
||||
if(posts.empty()) // means we have a comment or a vote
|
||||
{
|
||||
msg_ids.clear();
|
||||
|
||||
for(auto c:comments) msg_ids.insert(c.mMeta.mThreadId);
|
||||
for(auto v:votes ) msg_ids.insert(v.mMeta.mThreadId);
|
||||
|
||||
comments.clear();
|
||||
votes.clear();
|
||||
|
||||
if(!rsGxsChannels->getChannelContent(E.mChannelGroupId,msg_ids,posts,comments,votes))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl;
|
||||
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(E.mChannelGroupId,std::set<RsGxsMessageId>{ E.mChannelMsgId },comments))
|
||||
if(!rsGxsChannels->getChannelComments(E.mChannelGroupId,msg_ids,comments))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve message comment data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl;
|
||||
return;
|
||||
|
@ -183,7 +183,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
p.drawPixmap(mZoom*QPoint(0.1*fm.height(),-3.4*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*6*fm.height(),mZoom*6*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||
}
|
||||
|
||||
if(post.mCommentCount)
|
||||
if(post.mUnreadCommentCount)
|
||||
{
|
||||
QPainter p(&pixmap);
|
||||
QFontMetricsF fm(option.font);
|
||||
|
Loading…
Reference in New Issue
Block a user