Commit d7c1a063 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

conversationmodel: avoid useless iteration

Also fix setMessageDisplayed for clients

Change-Id: Ia2f8f586d88736a597e2271d2fd59402664ea3e6
GitLab: https://git.jami.net/savoirfairelinux/ring-project/-/issues/1282
parent cfeb273d
......@@ -1476,22 +1476,24 @@ ConversationModel::clearUnreadInteractions(const QString& convId)
{
std::lock_guard<std::mutex> lk(pimpl_->interactionsLocks[convId]);
auto& interactions = conversation.interactions;
std::for_each(interactions.begin(),
interactions.end(),
[&](decltype(*interactions.begin())& it) {
if (!it.second.isRead) {
emitUpdated = true;
it.second.isRead = true;
if (conversation.isSwarm()) {
lastDisplayed = it.first;
return;
if (conversation.isSwarm()) {
emitUpdated = true;
if (!interactions.empty())
lastDisplayed = interactions.rbegin()->first;
} else {
std::for_each(interactions.begin(),
interactions.end(),
[&](decltype(*interactions.begin())& it) {
if (!it.second.isRead) {
emitUpdated = true;
it.second.isRead = true;
if (owner.profileInfo.type != profile::Type::SIP)
lastDisplayed = storage::getDaemonIdByInteractionId(pimpl_->db,
it.first);
storage::setInteractionRead(pimpl_->db, it.first);
}
if (owner.profileInfo.type != profile::Type::SIP)
lastDisplayed = storage::getDaemonIdByInteractionId(pimpl_->db,
it.first);
storage::setInteractionRead(pimpl_->db, it.first);
}
});
});
}
}
if (!lastDisplayed.isEmpty()) {
auto to = conversation.isSwarm()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment