cleanup reply code a bit, have only 1 path to send message

This commit is contained in:
Bruno Windels 2023-01-17 12:32:05 +01:00
parent e33209b747
commit dfaaf6d234
4 changed files with 8 additions and 7 deletions

View File

@ -237,7 +237,7 @@ room.sendEvent(eventEntry.eventType, replacement);
## Replies
```js
const reply = eventEntry.reply({});
const reply = eventEntry.createReplyContent({});
room.sendEvent("m.room.message", reply);
```

View File

@ -200,13 +200,14 @@ export class RoomViewModel extends ErrorReportViewModel {
message = message.substr(4).trim();
msgtype = "m.emote";
}
let content;
if (replyingTo) {
log.set("replyingTo", replyingTo.eventId);
// TODO: reply should not send? it should just return the content for the reply and we send it ourselves
await replyingTo.reply(msgtype, message);
content = await replyingTo.createReplyContent(msgtype, message);
} else {
await this._room.sendEvent("m.room.message", {msgtype, body: message}, undefined, log);
content = {msgtype, body: message};
}
await this._room.sendEvent("m.room.message", content, undefined, log);
success = true;
}
log.set("success", success);

View File

@ -146,8 +146,8 @@ export class BaseMessageTile extends SimpleTile {
this._roomVM.startReply(this._entry);
}
reply(msgtype, body, log = null) {
return this._room.sendEvent("m.room.message", this._entry.reply(msgtype, body), null, log);
createReplyContent(msgtype, body) {
return this._entry.createReplyContent(msgtype, body);
}
redact(reason, log) {

View File

@ -181,7 +181,7 @@ export class BaseEventEntry extends BaseEntry {
return createAnnotation(this.id, key);
}
reply(msgtype, body) {
createReplyContent(msgtype, body) {
return createReplyContent(this, msgtype, body);
}