Mercurial > libervia-desktop-kivy
comparison libervia/desktop_kivy/core/common.py @ 503:d1a023280733
core (common): fix avatar retrieval in `JidItem`
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 25 Oct 2023 15:20:58 +0200 |
parents | b3cedbee561d |
children | 196483685a63 |
comparison
equal
deleted
inserted
replaced
502:4d45bed01183 | 503:d1a023280733 |
---|---|
32 from kivy import properties | 32 from kivy import properties |
33 from libervia.backend.core.i18n import _ | 33 from libervia.backend.core.i18n import _ |
34 from libervia.backend.core import log as logging | 34 from libervia.backend.core import log as logging |
35 from libervia.backend.tools.common import data_format | 35 from libervia.backend.tools.common import data_format |
36 from libervia.frontends.quick_frontend import quick_chat | 36 from libervia.frontends.quick_frontend import quick_chat |
37 from libervia.frontends.tools import aio | |
37 from .constants import Const as C | 38 from .constants import Const as C |
38 from .common_widgets import CategorySeparator | 39 from .common_widgets import CategorySeparator |
39 from .image import Image, AsyncImage | 40 from .image import Image, AsyncImage |
40 from libervia.desktop_kivy import G | 41 from libervia.desktop_kivy import G |
41 | 42 |
145 host = G.host | 146 host = G.host |
146 if host.contact_lists[self.profile].is_room(self.jid.bare): | 147 if host.contact_lists[self.profile].is_room(self.jid.bare): |
147 self.avatar.opacity = 0 | 148 self.avatar.opacity = 0 |
148 self.avatar.source = "" | 149 self.avatar.source = "" |
149 else: | 150 else: |
150 self.avatar.source = ( | 151 if not self.avatar.source: |
151 host.get_avatar(self.jid, profile=self.profile) | 152 aio.run_async(self._get_avatar()) |
152 or host.get_default_avatar(self.jid) | 153 |
153 ) | 154 async def _get_avatar(self) -> None: |
155 avatar_data = data_format.deserialise( | |
156 await G.host.a_bridge.avatar_get(self.jid, True, self.profile) | |
157 ) | |
158 self.avatar.source = ( | |
159 avatar_data.get("path") | |
160 or G.host.get_default_avatar(self.jid) | |
161 ) | |
154 | 162 |
155 | 163 |
156 class JidButton(ButtonBehavior, JidItem): | 164 class JidButton(ButtonBehavior, JidItem): |
157 pass | 165 pass |
158 | 166 |