From a3b935effb163bff30af2865df393ce69a78d8ea Mon Sep 17 00:00:00 2001 From: f0x Date: Thu, 18 Apr 2019 14:35:58 +0200 Subject: [PATCH] user avatars, proper event body display --- components/chat.js | 15 +++++++++++++-- components/events/text.js | 24 ++++++++++++++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/components/chat.js b/components/chat.js index f728304..b92863d 100644 --- a/components/chat.js +++ b/components/chat.js @@ -116,10 +116,21 @@ let EventGroup = create({ getInitialState: function() { let user = this.props.client.getUser(this.props.events[0].sender) + let avatar = + + if (user.avatarUrl != null) { + let hs = this.props.client.baseUrl + let media_mxc = user.avatarUrl.slice(6) + let url = `${hs}/_matrix/media/v1/thumbnail/${media_mxc}?width=128&height=128&method=scale` + avatar = + } + + console.log(user) let color = ["red", "green", "yellow", "blue", "purple", "cyan"][Math.floor(Math.random()*6)] return { color: color, - user: user + user: user, + avatar: avatar } }, @@ -132,7 +143,7 @@ let EventGroup = create({ return }) return
- + {this.state.avatar}
{this.state.user.displayName}
{events} diff --git a/components/events/text.js b/components/events/text.js index 40c1bbd..75c3c8f 100644 --- a/components/events/text.js +++ b/components/events/text.js @@ -10,8 +10,23 @@ let Event = create({ displayName: "m.text", render: function() { - let event = this.props.event; - let eventBody = riot.sanitize(event.content.body) + let event = this.props.event + + let eventBody + + if (event.content.format == "org.matrix.custom.html") { + let html = riot.sanitize(event.content.formatted_body) + eventBody =
+ } else { + eventBody = +
+ {event.content.body} +
+ } + let eventClass = "event" if (event.local) { @@ -19,10 +34,7 @@ let Event = create({ } return
-
+ {eventBody}
} })