Mercurial > libervia-web
changeset 1562:4afafce0c4c9
browser (calls): correctly display avatar and entity in status on incoming call
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 17 Aug 2023 14:59:01 +0200 |
parents | 7dbb131bbb9e |
children | e3449beac8d8 |
files | libervia/web/pages/calls/_browser/__init__.py |
diffstat | 1 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/web/pages/calls/_browser/__init__.py Thu Aug 17 14:58:21 2023 +0200 +++ b/libervia/web/pages/calls/_browser/__init__.py Thu Aug 17 14:59:01 2023 +0200 @@ -151,6 +151,20 @@ else: raise ValueError("Invalid call mode") + def set_avatar(self, entity_jid: JID|str) -> None: + """Set the avatar element from entity_jid + + @param entity_jid: bare jid of the entity + """ + call_avatar_elt = self.call_avatar_tpl.get_elt( + { + "entity": str(entity_jid), + "identities": cache.identities, + } + ) + self.call_avatar_wrapper_elt.clear() + self.call_avatar_wrapper_elt <= call_avatar_elt + def _on_action_new( self, action_data_s: str, action_id: str, security_limit: int, profile: str ) -> None: @@ -167,7 +181,7 @@ aio.run(self.on_action_new(action_data, action_id)) async def on_action_new(self, action_data: dict, action_id: str) -> None: - peer_jid = action_data["from_jid"] + peer_jid = JID(action_data["from_jid"]).bare log.info(f"{peer_jid} wants to start a call ({action_data['sub_type']})") if self.sid is not None: log.warning( @@ -178,6 +192,7 @@ sid = self.sid = action_data["session_id"] await cache.fill_identities([peer_jid]) identity = cache.identities[peer_jid] + self._callee = peer_jid peer_name = identity["nicknames"][0] # we start the ring @@ -206,6 +221,7 @@ log.debug(f"Call SID: {sid}") # Answer the call + self.set_avatar(peer_jid) self.status = "connecting" self.switch_mode("call") else: @@ -308,14 +324,7 @@ self._callee = callee_jid await cache.fill_identities([callee_jid]) self.status = "dialing" - call_avatar_elt = self.call_avatar_tpl.get_elt( - { - "entity": str(callee_jid), - "identities": cache.identities, - } - ) - self.call_avatar_wrapper_elt.clear() - self.call_avatar_wrapper_elt <= call_avatar_elt + self.set_avatar(callee_jid) self.switch_mode("call") await self.webrtc.make_call(callee_jid, audio, video)