From 93851248c1a59b2f95e5676fd7db834f3f7a5cf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 16 Feb 2022 14:07:09 -0500
Subject: [PATCH] conversationmodel: update presence for swarm

If a member presence is updated, the swarm presence can be updated

https://git.jami.net/savoirfairelinux/jami-client-qt/-/issues/670

Change-Id: I00450e4dadd4c614bec2b548be5f675555492344
---
 src/conversationmodel.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp
index 88100f39..41db5deb 100644
--- a/src/conversationmodel.cpp
+++ b/src/conversationmodel.cpp
@@ -2819,13 +2819,14 @@ ConversationModelPimpl::slotContactRemoved(const QString& uri)
 void
 ConversationModelPimpl::slotContactModelUpdated(const QString& uri)
 {
-    try {
-        auto& conversation = getConversationForPeerUri(uri, true).get();
-        invalidateModel();
-        emit linked.conversationUpdated(conversation.uid);
-        Q_EMIT linked.dataChanged(indexOf(conversation.uid));
-    } catch (std::out_of_range&) {
-        qDebug() << "contact update attempted for inexistent conversation";
+    // Update presence for all conversations with this peer
+    for (auto& conversation : conversations) {
+        auto members = peersForConversation(conversation);
+        if (members.indexOf(uri) != -1) {
+            invalidateModel();
+            emit linked.conversationUpdated(conversation.uid);
+            Q_EMIT linked.dataChanged(indexOf(conversation.uid));
+        }
     }
 
     if (currentFilter.isEmpty()) {
-- 
GitLab