From 811b5877b0bed603cf28a1d6de6bcb9dc4de9b98 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 31 Aug 2019 12:44:32 +0300 Subject: [PATCH] Fix previous commit --- maubot/client.py | 6 ++-- .../frontend/src/pages/dashboard/Client.js | 28 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/maubot/client.py b/maubot/client.py index 6014e0a..6edc2f5 100644 --- a/maubot/client.py +++ b/maubot/client.py @@ -46,8 +46,8 @@ class Client: client: MaubotMatrixClient started: bool - remote_displayname: str - remote_avatar_url: ContentURI + remote_displayname: Optional[str] + remote_avatar_url: Optional[ContentURI] def __init__(self, db_instance: DBClient) -> None: self.db_instance = db_instance @@ -56,6 +56,8 @@ class Client: self.references = set() self.started = False self.sync_ok = True + self.remote_displayname = None + self.remote_avatar_url = None self.client = MaubotMatrixClient(mxid=self.id, base_url=self.homeserver, token=self.access_token, client_session=self.http_client, log=self.log, loop=self.loop, store=self.db_instance) diff --git a/maubot/management/frontend/src/pages/dashboard/Client.js b/maubot/management/frontend/src/pages/dashboard/Client.js index a572591..062d6ad 100644 --- a/maubot/management/frontend/src/pages/dashboard/Client.js +++ b/maubot/management/frontend/src/pages/dashboard/Client.js @@ -30,18 +30,24 @@ const ClientListEntry = ({ entry }) => { } else if (!entry.started) { classes.push("stopped") } - const avatarURL = entry.avatar_url && api.getAvatarURL({ + const avatarMXC = entry.avatar_url === "disable" + ? entry.remote_avatar_url + : entry.avatar_url + const avatarURL = avatarMXC && api.getAvatarURL({ id: entry.id, - avatar_url: entry.avatar_url === "disabled" - ? entry.remote_avatar_url - : entry.avatar_url + avatar_url: avatarMXC, }) + const displayname = ( + entry.displayname === "disable" + ? entry.remote_displayname + : entry.displayname + ) || entry.id return ( {avatarURL ? : } - {entry.displayname || entry.id} + {displayname} ) @@ -203,20 +209,22 @@ class Client extends BaseMainView { } + get avatarMXC() { + return this.state.avatar_url === "disable" ? this.props.entry.remote_avatar_url : this.state.avatar_url + } + get avatarURL() { return api.getAvatarURL({ id: this.state.id, - avatar_url: this.state.avatar_url === "disabled" - ? this.props.entry.remote_avatar_url - : this.state.avatar_url + avatar_url: this.avatarMXC, }) } renderSidebar = () => !this.isNew && (
-
- Avatar + {this.avatarMXC && Avatar}