From fe0ef61fd73d6c7181fc61b0df02b75564119ac1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 29 Jun 2021 10:05:05 -0400
Subject: [PATCH] conversationmodel: fix isCoreDialog assumption

a one to one swarm is always a core dialog and should override all non swarm anyway.
Moreover, for the first interaction ever, the conversation's request can come
after. For example if alice calls bob, the call can come before the conversation's
request. The details of the contact will not link to any conversation leading
to a duplicate.

Change-Id: I7d68b2dee8ca2b42b12e22693388f7616c148d0a
GitLab: https://git.jami.net/savoirfairelinux/jami-client-qt/-/issues/455
---
 src/conversationmodel.cpp | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp
index 3e88ed3e..be6cc000 100644
--- a/src/conversationmodel.cpp
+++ b/src/conversationmodel.cpp
@@ -1977,19 +1977,8 @@ ConversationModelPimpl::isCoreDialog(const conversation::Info& conversation) con
 {
     switch (conversation.mode) {
     case conversation::Mode::NON_SWARM:
-        return true;
     case conversation::Mode::ONE_TO_ONE:
-        try {
-            // for active one-to-one conversation conversationId should be set
-            auto& peers = peersForConversation(conversation);
-            if (peers.size() != 1) {
-                return false;
-            }
-            auto contactInfo = linked.owner.contactModel->getContact(peers.front());
-            return !contactInfo.conversationId.isEmpty();
-        } catch (...) {
-            return true;
-        }
+        return true;
     default:
         break;
     }
@@ -2849,7 +2838,10 @@ ConversationModelPimpl::getConversationForPeerUri(const QString& uri,
             if (!isCoreDialog(conv)) {
                 return false;
             }
-            return uri == peersForConversation(conv).front();
+            auto members = peersForConversation(conv);
+            if (members.isEmpty())
+                return false;
+            return members.indexOf(uri) != -1;
         },
         searchResultIncluded);
 }
-- 
GitLab