Fix previous commit
This commit is contained in:
parent
c9c8ac08a1
commit
811b5877b0
2 changed files with 22 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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 (
|
||||
<NavLink className={classes.join(" ")} to={`/client/${entry.id}`}>
|
||||
{avatarURL
|
||||
? <img className='avatar' src={avatarURL} alt=""/>
|
||||
: <NoAvatarIcon className='avatar'/>}
|
||||
<span className="displayname">{entry.displayname || entry.id}</span>
|
||||
<span className="displayname">{displayname}</span>
|
||||
<ChevronRight className='chevron'/>
|
||||
</NavLink>
|
||||
)
|
||||
|
@ -203,20 +209,22 @@ class Client extends BaseMainView {
|
|||
</div>
|
||||
}
|
||||
|
||||
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 && (
|
||||
<div className="sidebar">
|
||||
<div className={`avatar-container ${this.state.avatar_url ? "" : "no-avatar"}
|
||||
<div className={`avatar-container ${this.avatarMXC ? "" : "no-avatar"}
|
||||
${this.state.uploadingAvatar ? "uploading" : ""}`}>
|
||||
<img className="avatar" src={this.avatarURL} alt="Avatar"/>
|
||||
{this.avatarMXC && <img className="avatar" src={this.avatarURL} alt="Avatar"/>}
|
||||
<UploadButton className="upload"/>
|
||||
<input className="file-selector" type="file" accept="image/png, image/jpeg"
|
||||
onChange={this.avatarUpload} disabled={this.state.uploadingAvatar}
|
||||
|
|
Loading…
Reference in a new issue