From 0adc815a38ca40dad47937900ef9f41a97b74c9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 20 Dec 2021 12:02:23 -0500
Subject: [PATCH] profiles: do not cache avatars in LRC

This reduces memory usage.

Change-Id: Iddb54a844ffacfc96b7758b2a9317e68e04750c4
---
 src/mainapplication.cpp | 1 +
 src/utils.cpp           | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp
index 278f19287..6c9832119 100644
--- a/src/mainapplication.cpp
+++ b/src/mainapplication.cpp
@@ -315,6 +315,7 @@ MainApplication::loadTranslations()
 void
 MainApplication::initLrc(const QString& downloadUrl, ConnectivityMonitor* cm, bool logDaemon)
 {
+    lrc::api::Lrc::cacheAvatars.store(false);
     /*
      * Init mainwindow and finish splash when mainwindow shows up.
      */
diff --git a/src/utils.cpp b/src/utils.cpp
index 3d647c796..e19d895b5 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -357,7 +357,7 @@ Utils::contactPhoto(LRCInstance* instance,
         auto& accInfo = instance->accountModel().getAccountInfo(
             accountId.isEmpty() ? instance->get_currentAccountId() : accountId);
         auto contactInfo = accInfo.contactModel->getContact(contactUri);
-        auto contactPhoto = contactInfo.profileInfo.avatar;
+        auto contactPhoto = accInfo.contactModel->avatar(contactUri);
         auto bestName = accInfo.contactModel->bestNameForContact(contactUri);
         if (accInfo.profileInfo.type == profile::Type::SIP
             && contactInfo.profileInfo.type == profile::Type::TEMPORARY) {
-- 
GitLab