From 92543321a082a94a3035024595d09438ed524680 Mon Sep 17 00:00:00 2001 From: f0x Date: Fri, 3 May 2019 11:58:53 +0200 Subject: [PATCH] working replies with clearing on click --- components/chat.js | 20 +++++++++++--------- components/input.js | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/components/chat.js b/components/chat.js index 80c310c..2f89002 100644 --- a/components/chat.js +++ b/components/chat.js @@ -26,19 +26,20 @@ jdenticon.config = { backColor: "#00000000" }; -sdk.MatrixEvent.prototype.plaintext = function() { - let event = this.event - let plain = "unknown event" +let eventFunctions = { + plaintext: function() { + let plain = "unknown event" - if (event.type == "m.room.message") { - plain = event.content.body + if (this.type == "m.room.message") { + plain = this.content.body - if (event.content.format == "org.matrix.custom.html") { - plain = sanitize(event.content.formatted_body, {allowedTags: []}) + if (this.content.format == "org.matrix.custom.html") { + plain = sanitize(this.content.formatted_body, {allowedTags: []}) + } } - } - return plain + return plain + } } let chat = create({ @@ -106,6 +107,7 @@ let chat = create({ if (room.timeline.length > 0) { room.timeline.forEach((MatrixEvent) => { let event = MatrixEvent.event; + event = Object.assign(event, eventFunctions) if (event.user_id != null) { // localecho messages event.sender = event.user_id event.local = true diff --git a/components/input.js b/components/input.js index 6bf718c..62ab7ef 100644 --- a/components/input.js +++ b/components/input.js @@ -109,7 +109,7 @@ let input = create({ render: function() { return
{this.props.replyEvent && -
+
this.props.onReplyClick()}> {this.props.replyEvent.plaintext()}
}