diff --git a/src/components/Chat.vue b/src/components/Chat.vue index c0d5c00..93c6603 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -511,18 +511,12 @@ export default { sendMessage() { if (this.currentInput.length > 0) { - // Is this an edit? - if (this.editedEvent) { - console.log("Edit"); - } - - this.editedEvent = null; //TODO - Is this a good place to reset this? - util .sendTextMessage( this.$matrix.matrixClient, this.roomId, - this.currentInput + this.currentInput, + this.editedEvent ) .then(() => { console.log("Sent message"); @@ -531,6 +525,7 @@ export default { console.log("Failed to send:", err); }); this.currentInput = ""; + this.editedEvent = null; //TODO - Is this a good place to reset this? } }, @@ -678,6 +673,7 @@ export default { edit(event) { this.editedEvent = event; this.currentInput = event.getContent().body; + this.$refs.messageInput.focus(); }, emojiSelected(e) { diff --git a/src/plugins/utils.js b/src/plugins/utils.js index 0993c7a..f12049b 100644 --- a/src/plugins/utils.js +++ b/src/plugins/utils.js @@ -113,8 +113,19 @@ class Util { }); } - sendTextMessage(matrixClient, roomId, text) { - return this.sendMessage(matrixClient, roomId, "m.room.message", ContentHelpers.makeTextMessage(text)); + sendTextMessage(matrixClient, roomId, text, editedEvent) { + var content = ContentHelpers.makeTextMessage(text); + if (editedEvent) { + content['m.relates_to'] = { + rel_type: 'm.replace', + event_id: editedEvent.getId() + } + content['m.new_content'] = { + body: content.body, + msgtype: content.msgtype + } + } + return this.sendMessage(matrixClient, roomId, "m.room.message", content); } sendQuickReaction(matrixClient, roomId, emoji, event) {