From c2dfaa3f4061631ce8111aeb1f9132cd4c61dcbc Mon Sep 17 00:00:00 2001 From: f0x Date: Fri, 26 Apr 2019 14:25:01 +0200 Subject: [PATCH] sending basic replies --- components/chat.js | 10 +++++++--- components/events/Event.js | 3 +-- components/input.js | 21 +++++++++++++++++++++ public/scss/style.scss | 10 ++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/components/chat.js b/components/chat.js index cf387be..6db7717 100644 --- a/components/chat.js +++ b/components/chat.js @@ -56,6 +56,10 @@ let chat = create({ } }, + onReplyClick: function(e) { + this.setState({replyEvent: e}) + }, + render: function() { let empty = (
@@ -100,7 +104,7 @@ let chat = create({ messageGroups.groups.push(messageGroups.current) events = messageGroups.groups.map((events, id) => { - return + return }) } //TODO: replace with something that only renders events in view @@ -112,7 +116,7 @@ let chat = create({ {events}
- + ) } @@ -146,7 +150,7 @@ let EventGroup = create({ render: function() { let events = this.props.events.map((event, key) => { - return + return }) return
{this.state.avatar} diff --git a/components/events/Event.js b/components/events/Event.js index 4b236fa..1bf4749 100644 --- a/components/events/Event.js +++ b/components/events/Event.js @@ -63,8 +63,7 @@ let Event = create({ } return ( -
{console.log(parsedBody, event) - }}> +
{this.props.onReplyClick(event)}}> {reply} {element}
diff --git a/components/input.js b/components/input.js index 65d1bd7..ba3efc5 100644 --- a/components/input.js +++ b/components/input.js @@ -71,6 +71,7 @@ let input = create({ body: string, msgtype: "m.text" } + content = this.sendReply(content) this.props.client.sendEvent(this.props.roomId, "m.room.message", content, (err, res) => { console.log(err) }) @@ -83,13 +84,33 @@ let input = create({ format: "org.matrix.custom.html", msgtype: "m.text" } + + content = this.sendReply(content) + this.props.client.sendEvent(this.props.roomId, "m.room.message", content, (err, res) => { console.log(err) }) }, + sendReply: function(content) { + if (this.props.replyEvent != undefined) { + content['m.relates_to'] = { + 'm.in_reply_to': { + event_id: this.props.replyEvent.event_id + } + } + this.props.onReplyClick() + } + return content + }, + render: function() { return
+ {this.props.replyEvent && +
+ {this.props.replyEvent.content.body} +
+ }
} diff --git a/public/scss/style.scss b/public/scss/style.scss index 4b10aa7..f1bdd3e 100644 --- a/public/scss/style.scss +++ b/public/scss/style.scss @@ -361,8 +361,18 @@ body { .input { display: flex; + flex-direction: column; border-top: $borderwidth solid transparent; + .replyEvent { + border-bottom: $borderwidth/2 solid $bg3; + padding: $spacing/2 $spacing; + max-width: 100%; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + } + textarea { background: transparent; box-sizing: border-box;