Edit events
This commit is contained in:
parent
24b72cab1e
commit
a4c329100d
2 changed files with 17 additions and 10 deletions
|
|
@ -511,18 +511,12 @@ export default {
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
if (this.currentInput.length > 0) {
|
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
|
util
|
||||||
.sendTextMessage(
|
.sendTextMessage(
|
||||||
this.$matrix.matrixClient,
|
this.$matrix.matrixClient,
|
||||||
this.roomId,
|
this.roomId,
|
||||||
this.currentInput
|
this.currentInput,
|
||||||
|
this.editedEvent
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("Sent message");
|
console.log("Sent message");
|
||||||
|
|
@ -531,6 +525,7 @@ export default {
|
||||||
console.log("Failed to send:", err);
|
console.log("Failed to send:", err);
|
||||||
});
|
});
|
||||||
this.currentInput = "";
|
this.currentInput = "";
|
||||||
|
this.editedEvent = null; //TODO - Is this a good place to reset this?
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -678,6 +673,7 @@ export default {
|
||||||
edit(event) {
|
edit(event) {
|
||||||
this.editedEvent = event;
|
this.editedEvent = event;
|
||||||
this.currentInput = event.getContent().body;
|
this.currentInput = event.getContent().body;
|
||||||
|
this.$refs.messageInput.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
emojiSelected(e) {
|
emojiSelected(e) {
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,19 @@ class Util {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTextMessage(matrixClient, roomId, text) {
|
sendTextMessage(matrixClient, roomId, text, editedEvent) {
|
||||||
return this.sendMessage(matrixClient, roomId, "m.room.message", ContentHelpers.makeTextMessage(text));
|
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) {
|
sendQuickReaction(matrixClient, roomId, emoji, event) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue