From 98569e2c707e0d3e558ebbfdc2b2b44d7623456e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Fri, 3 Mar 2023 15:19:24 -0500
Subject: [PATCH] smartlist: reload messages on language change

Change-Id: I50893c6296040ad6bc972050d595cdedd27f635c
GitLab: #936
---
 src/app/calladapter.cpp                              |  3 ++-
 src/app/currentcall.cpp                              |  3 ++-
 .../mainview/components/SmartListItemDelegate.qml    |  7 +++++++
 src/app/utilsadapter.cpp                             | 12 +++++-------
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/app/calladapter.cpp b/src/app/calladapter.cpp
index cbb99d173..340958773 100644
--- a/src/app/calladapter.cpp
+++ b/src/app/calladapter.cpp
@@ -521,7 +521,8 @@ CallAdapter::updateCall(const QString& convUid, const QString& accountId, bool f
                 if (call->status == call::Status::IN_PROGRESS
                     || call->status == call::Status::PAUSED)
                     accInfo.callModel->setCurrentCall(call->id);
-            } catch (...) {}
+            } catch (...) {
+            }
         }
     }
 
diff --git a/src/app/currentcall.cpp b/src/app/currentcall.cpp
index a3f99e753..9213d04ff 100644
--- a/src/app/currentcall.cpp
+++ b/src/app/currentcall.cpp
@@ -68,7 +68,8 @@ CurrentCall::updateId(QString callId)
             if (callInfo.status == call::Status::IN_PROGRESS
                 || callInfo.status == call::Status::PAUSED)
                 accInfo.callModel->setCurrentCall(callId);
-        } catch (...) {}
+        } catch (...) {
+        }
     }
     // Set the current id_ if there is a call.
     set_id((accInfo.callModel->hasCall(callId) ? callId : QString()));
diff --git a/src/app/mainview/components/SmartListItemDelegate.qml b/src/app/mainview/components/SmartListItemDelegate.qml
index fe1a4e060..f8c34acb7 100644
--- a/src/app/mainview/components/SmartListItemDelegate.qml
+++ b/src/app/mainview/components/SmartListItemDelegate.qml
@@ -46,6 +46,13 @@ ItemDelegate {
 
     property string lastInteractionFormattedDate: MessagesAdapter.getBestFormattedDate(lastInteractionDate)
 
+    Connections {
+        target: UtilsAdapter
+        function onChangeLanguage() {
+            UtilsAdapter.clearInteractionsCache(root.accountId, root.convId)
+        }
+    }
+
     onVisibleChanged: {
         if (visible)
             return
diff --git a/src/app/utilsadapter.cpp b/src/app/utilsadapter.cpp
index c6d9654db..52f353b9c 100644
--- a/src/app/utilsadapter.cpp
+++ b/src/app/utilsadapter.cpp
@@ -469,13 +469,11 @@ UtilsAdapter::monitor(const bool& continuous)
 void
 UtilsAdapter::clearInteractionsCache(const QString& accountId, const QString& convId)
 {
-    if (lrcInstance_->get_selectedConvUid() != convId) {
-        try {
-            auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
-            auto& convModel = accInfo.conversationModel;
-            convModel->clearInteractionsCache(convId);
-        } catch (...) {
-        }
+    try {
+        auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
+        auto& convModel = accInfo.conversationModel;
+        convModel->clearInteractionsCache(convId);
+    } catch (...) {
     }
 }
 
-- 
GitLab