added missing code for marking all msgs as read/unread

This commit is contained in:
csoler 2020-09-27 23:21:03 +02:00
parent ff0836929d
commit 819035472d
3 changed files with 25 additions and 1 deletions

View File

@ -658,7 +658,13 @@ QIcon PostedListWidgetWithModel::groupIcon()
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
{
std::cerr << __PRETTY_FUNCTION__ << ": not implemented" << std::endl;
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
return;
QModelIndex src_index;
mPostedPostsModel->setAllMsgReadStatus(read);
}
void PostedListWidgetWithModel::openComments(const RsGxsMessageId& msgId)

View File

@ -715,6 +715,23 @@ void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
}
}
void RsPostedPostsModel::setAllMsgReadStatus(bool read)
{
// make a temporary listof pairs
std::list<RsGxsGrpMsgIdPair> pairs;
for(uint32_t i=0;i<mPosts.size();++i)
pairs.push_back(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId));
RsThread::async([read,pairs]()
{
// Call blocking API
for(auto& p:pairs)
rsPosted->setPostReadStatus(p,read);
} );
}
void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
{
if(!i.isValid())

View File

@ -154,6 +154,7 @@ public:
void setTextColorMissing (QColor color) { mTextColorMissing = color;}
#endif
void setAllMsgReadStatus(bool read);
void setMsgReadStatus(const QModelIndex &i, bool read_status);
void setFilter(const QStringList &strings, uint32_t &count) ;
void setSortingStrategy(SortingStrategy s);