From 9e12d838500db1d90ecd42770b36eec35e5009d6 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Thu, 7 Apr 2022 11:42:32 -0400
Subject: [PATCH] contactmodel: include search results when finding a contact
 name

Since we display the title in the smartlist now, we need to check
the search result list in the case where the contact is not found
when acquiring a best-name.

Change-Id: Iee808b7137edfb6265e8ad4491c8354e3fcd9bcf
---
 src/contactmodel.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp
index 0f043043..2a716dcf 100644
--- a/src/contactmodel.cpp
+++ b/src/contactmodel.cpp
@@ -523,14 +523,14 @@ ContactModel::sendDhtMessage(const QString& contactUri, const QString& body) con
 const QString
 ContactModel::bestNameForContact(const QString& contactUri) const
 {
-    std::lock_guard<std::mutex> lk(pimpl_->contactsMtx_);
-    if (pimpl_->contacts.contains(contactUri)) {
-        auto contact = pimpl_->contacts.value(contactUri);
+    try {
+        auto contact = getContact(contactUri);
         auto alias = contact.profileInfo.alias.simplified();
         if (alias.isEmpty()) {
             return bestIdFromContactInfo(contact);
         }
         return alias;
+    } catch(const std::out_of_range&) {
     }
     return contactUri;
 }
-- 
GitLab