changeset 503:d1a023280733

core (common): fix avatar retrieval in `JidItem`
author Goffi <goffi@goffi.org>
date Wed, 25 Oct 2023 15:20:58 +0200
parents 4d45bed01183
children fe0bdc476576
files libervia/desktop_kivy/core/common.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/desktop_kivy/core/common.py	Wed Oct 04 23:17:06 2023 +0200
+++ b/libervia/desktop_kivy/core/common.py	Wed Oct 25 15:20:58 2023 +0200
@@ -34,6 +34,7 @@
 from libervia.backend.core import log as logging
 from libervia.backend.tools.common import data_format
 from libervia.frontends.quick_frontend import quick_chat
+from libervia.frontends.tools import aio
 from .constants import Const as C
 from .common_widgets import CategorySeparator
 from .image import Image, AsyncImage
@@ -147,10 +148,17 @@
             self.avatar.opacity = 0
             self.avatar.source = ""
         else:
-            self.avatar.source = (
-                host.get_avatar(self.jid, profile=self.profile)
-                or host.get_default_avatar(self.jid)
-            )
+            if not self.avatar.source:
+                aio.run_async(self._get_avatar())
+
+    async def _get_avatar(self) -> None:
+        avatar_data = data_format.deserialise(
+            await G.host.a_bridge.avatar_get(self.jid, True, self.profile)
+        )
+        self.avatar.source = (
+            avatar_data.get("path")
+            or G.host.get_default_avatar(self.jid)
+        )
 
 
 class JidButton(ButtonBehavior, JidItem):