Commit db943766 authored by Sébastien Blin's avatar Sébastien Blin

conversationmodel: only set displayed for latest interaction

This avoids some spam about displayed messages daemon side

Change-Id: I0df255671e63c0aece14109875c8662758fbf87d
parent 7b04cb70
......@@ -1177,22 +1177,25 @@ ConversationModel::clearUnreadInteractions(const QString& convId) {
return;
}
bool emitUpdated = false;
QString lastDisplayed;
{
std::lock_guard<std::mutex> lk(pimpl_->interactionsLocks[convId]);
auto& interactions = pimpl_->conversations[conversationIdx].interactions;
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) {
auto daemonId = storage::getDaemonIdByInteractionId(pimpl_->db, QString::number(it.first));
ConfigurationManager::instance().setMessageDisplayed(owner.id, pimpl_->conversations[conversationIdx].participants.front(), daemonId, 3);
}
storage::setInteractionRead(pimpl_->db, it.first);
}
});
}
[&] (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, QString::number(it.first));
storage::setInteractionRead(pimpl_->db, it.first);
}
});
}
if (!lastDisplayed.isEmpty())
ConfigurationManager::instance().setMessageDisplayed(
owner.id, pimpl_->conversations[conversationIdx].participants.front(), lastDisplayed, 3
);
if (emitUpdated) {
pimpl_->conversations[conversationIdx].unreadMessages = 0;
pimpl_->dirtyConversations = {true, true};
......
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