From 95094a222c6fac625b965eddcb2036dd3a2a7db7 Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <katryna.kostiuk@savoirfairelinux.com> Date: Wed, 29 Mar 2023 10:11:44 -0400 Subject: [PATCH] conversations: add API to reload conversations On iOS, both Jami.app and notifications extension could modify conversations and requests files. This patch adds API to reload conversations and requests so Jami.app and notifications extension could have up to date information. Change-Id: I5873bc69c329bd6c78e7f4d60a01c9471e19bcd1 --- src/client/conversation_interface.cpp | 11 +++++++++++ src/jami/conversation_interface.h | 1 + src/jamidht/jamiaccount.cpp | 9 --------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/client/conversation_interface.cpp b/src/client/conversation_interface.cpp index 80cb2fc18b..661832b96f 100644 --- a/src/client/conversation_interface.cpp +++ b/src/client/conversation_interface.cpp @@ -247,4 +247,15 @@ searchConversation(const std::string& accountId, return res; } +void +reloadConversationsAndRequests(const std::string& accountId) +{ + if (auto acc = jami::Manager::instance().getAccount<jami::JamiAccount>(accountId)) { + if (auto convModule = acc->convModule()) { + convModule->reloadRequests(); + convModule->loadConversations(); + } + } +} + } // namespace libjami diff --git a/src/jami/conversation_interface.h b/src/jami/conversation_interface.h index d11ae03b0e..163579a681 100644 --- a/src/jami/conversation_interface.h +++ b/src/jami/conversation_interface.h @@ -98,6 +98,7 @@ LIBJAMI_PUBLIC uint32_t searchConversation(const std::string& accountId, const int64_t& before, const uint32_t& maxResult, const int32_t& flag); +LIBJAMI_PUBLIC void reloadConversationsAndRequests(const std::string& accountId); struct LIBJAMI_PUBLIC ConversationSignal { diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 18b5db9a8a..a71a064cab 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -1476,15 +1476,6 @@ void JamiAccount::registerAsyncOps() { auto onLoad = [this, loaded = std::make_shared<std::atomic_uint>()] { - if (auto cm = convModule()) { - /* - On iOS, when the app is in the background, invitations are received - and saved by the notifications extension. - When app becomes active requests need to be reloaded, to retrieve invitations - received when app was in background. - */ - cm->reloadRequests(); - } if (++(*loaded) == 2u) { runOnMainThread([w = weak()] { if (auto s = w.lock()) { -- GitLab