From 8fe4a6ae43cdb80c02d0218250f49438cdf2adc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 5 Jul 2021 10:18:46 -0400 Subject: [PATCH] conversationmodel: show conversation's requests without contact This fix showing requests from a fresh import without knowing contacts informations. https://git.jami.net/savoirfairelinux/jami-client-qt/-/issues/455 Change-Id: Ieb4018b53c17ba13700d2cddb27cadc42f507ded --- src/conversationmodel.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index 166c8dee..678ff9d9 100644 --- a/src/conversationmodel.cpp +++ b/src/conversationmodel.cpp @@ -582,14 +582,16 @@ ConversationModel::getFilteredConversations(const FilterType& filter, return pimpl_->customFilteredConversations.reset(pimpl_->conversations) .filter([this, &includeBanned](const conversation::Info& entry) { try { - auto& peers = pimpl_->peersForConversation(entry); - if (peers.isEmpty()) { - return false; + if (entry.isNotASwarm()) { + auto& peers = pimpl_->peersForConversation(entry); + if (peers.isEmpty()) { + return false; + } + auto contactInfo = owner.contactModel->getContact(peers.front()); + // do not check blocked contacts for conversation with many participants + if (!includeBanned && (contactInfo.isBanned && peers.size() == 1)) + return false; } - auto contactInfo = owner.contactModel->getContact(peers.front()); - // do not check blocked contacts for conversation with many participants - if (!includeBanned && (contactInfo.isBanned && peers.size() == 1)) - return false; switch (pimpl_->customTypeFilter) { case FilterType::JAMI: // we have conversation with many participants only for JAMI @@ -1994,7 +1996,16 @@ ConversationModelPimpl::filter(const conversation::Info& entry) if (peers.size() < 1) { return false; } - auto contactInfo = linked.owner.contactModel->getContact(peers.front()); + auto uriPeer = peers.front(); + contact::Info contactInfo; + try { + contactInfo = linked.owner.contactModel->getContact(uriPeer); + } catch (...) { + // Note: as we search for contacts, when importing a new account, + // the conversation's request can be there without contact, causing + // the function to fail. + contactInfo.profileInfo.uri = uriPeer; + } auto uri = URI(currentFilter); bool stripScheme = (uri.schemeType() < URI::SchemeType::COUNT__); -- GitLab