mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
fixed marking all msgs as read/unread in channels
This commit is contained in:
parent
209355b9a5
commit
8c845d7419
@ -171,7 +171,7 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings, uint32_t& cou
|
|||||||
if(strings.empty())
|
if(strings.empty())
|
||||||
{
|
{
|
||||||
mFilteredPosts.clear();
|
mFilteredPosts.clear();
|
||||||
for(int i=0;i<mPosts.size();++i)
|
for(size_t i=0;i<mPosts.size();++i)
|
||||||
mFilteredPosts.push_back(i);
|
mFilteredPosts.push_back(i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -179,7 +179,7 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings, uint32_t& cou
|
|||||||
mFilteredPosts.clear();
|
mFilteredPosts.clear();
|
||||||
//mFilteredPosts.push_back(0);
|
//mFilteredPosts.push_back(0);
|
||||||
|
|
||||||
for(int i=0;i<mPosts.size();++i)
|
for(size_t i=0;i<mPosts.size();++i)
|
||||||
{
|
{
|
||||||
bool passes_strings = true;
|
bool passes_strings = true;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ bool RsGxsChannelPostsModel::convertRefPointerToTabEntry(quintptr ref, uint32_t&
|
|||||||
|
|
||||||
QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex & parent) const
|
QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
if(row < 0 || column < 0 || column >= mColumns)
|
if(row < 0 || column < 0 || column >= (int)mColumns)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
quintptr ref = getChildRef(parent.internalId(),column + row*mColumns);
|
quintptr ref = getChildRef(parent.internalId(),column + row*mColumns);
|
||||||
@ -684,7 +684,19 @@ void RsGxsChannelPostsModel::createPostsArray(std::vector<RsGxsChannelPost>& pos
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status,bool with_children)
|
void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status)
|
||||||
|
{
|
||||||
|
// No need to call preMods()/postMods() here because we're not changing the model
|
||||||
|
// All operations below are done async
|
||||||
|
|
||||||
|
RsThread::async([this, read_status]()
|
||||||
|
{
|
||||||
|
for(uint32_t i=0;i<mPosts.size();++i)
|
||||||
|
rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
|
||||||
{
|
{
|
||||||
if(!i.isValid())
|
if(!i.isValid())
|
||||||
return ;
|
return ;
|
||||||
@ -697,10 +709,7 @@ void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_sta
|
|||||||
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size())
|
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size())
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
#warning TODO
|
rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[mFilteredPosts[entry]].mMeta.mGroupId,mPosts[mFilteredPosts[entry]].mMeta.mMsgId),read_status);
|
||||||
// bool has_unread_below, has_read_below;
|
|
||||||
// recursSetMsgReadStatus(entry,read_status,with_children) ;
|
|
||||||
// recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
||||||
|
@ -127,7 +127,9 @@ public:
|
|||||||
void setTextColorMissing (QColor color) { mTextColorMissing = color;}
|
void setTextColorMissing (QColor color) { mTextColorMissing = color;}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children);
|
void setMsgReadStatus(const QModelIndex &i, bool read_status);
|
||||||
|
void setAllMsgReadStatus(bool read_status);
|
||||||
|
|
||||||
void setFilter(const QStringList &strings, uint32_t &count) ;
|
void setFilter(const QStringList &strings, uint32_t &count) ;
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
@ -1148,6 +1148,7 @@ public:
|
|||||||
uint32_t mLastToken;
|
uint32_t mLastToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
static void setAllMessagesReadCallback(FeedItem *feedItem, void *data)
|
static void setAllMessagesReadCallback(FeedItem *feedItem, void *data)
|
||||||
{
|
{
|
||||||
GxsChannelPostItem *channelPostItem = dynamic_cast<GxsChannelPostItem*>(feedItem);
|
GxsChannelPostItem *channelPostItem = dynamic_cast<GxsChannelPostItem*>(feedItem);
|
||||||
@ -1164,16 +1165,15 @@ static void setAllMessagesReadCallback(FeedItem *feedItem, void *data)
|
|||||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId());
|
RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId());
|
||||||
rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead);
|
rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
|
void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/)
|
||||||
{
|
{
|
||||||
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) {
|
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
GxsChannelPostsReadData data(read);
|
QModelIndex src_index;
|
||||||
//ui->feedWidget->withAll(setAllMessagesReadCallback, &data);
|
|
||||||
|
|
||||||
token = data.mLastToken;
|
mChannelPostsModel->setAllMsgReadStatus(read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user