From a44c2fc1541e2b175f3af045e454fb0bd185284d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 10 Aug 2023 14:18:23 -0400
Subject: [PATCH] conversation_module: loadConversations should fill from
 convInfos

This avoid to call getConversationMembers on conversations not yet
loaded from the daemon.

Change-Id: I8988dbdd01e3072f7ce0c23b99cf6283902ab63c
---
 src/jamidht/conversation_module.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/jamidht/conversation_module.cpp b/src/jamidht/conversation_module.cpp
index 7a7b331187..fd806193ca 100644
--- a/src/jamidht/conversation_module.cpp
+++ b/src/jamidht/conversation_module.cpp
@@ -1293,6 +1293,11 @@ ConversationModule::loadConversations()
         if (info.removed)
             removed.insert(info.id);
         auto itConv = pimpl_->conversations_.find(info.id);
+        if (itConv == pimpl_->conversations_.end()) {
+            // convInfos_ can contain a conversation that is not yet cloned
+            // so we need to add it there.
+            itConv = pimpl_->conversations_.emplace(info.id, std::make_shared<SyncedConversation>(info)).first;
+        }
         if (itConv != pimpl_->conversations_.end() && itConv->second && itConv->second->conversation && info.removed)
             itConv->second->conversation->setRemovingFlag();
         if (!info.removed && itConv == pimpl_->conversations_.end()) {
@@ -1382,11 +1387,8 @@ ConversationModule::bootstrap(const std::string& convId)
         std::lock_guard<std::mutex> lk(pimpl_->convInfosMtx_);
         for (const auto& [conversationId, convInfo] : pimpl_->convInfos_) {
             auto conv = pimpl_->getConversation(conversationId);
-            if (!conv) {
-                // convInfos_ can contain a conversation that is not yet cloned
-                // so we need to add it there.
-                conv = pimpl_->startConversation(convInfo);
-            }
+            if (!conv)
+                return;
             if ((!conv->conversation && !conv->info.removed)) {
                 // Because we're not tracking contact presence in order to sync now,
                 // we need to ask to clone requests when bootstraping all conversations
-- 
GitLab