Merge pull request #193 from vector-im/bwindels/emote

support emotes
This commit is contained in:
Bruno Windels 2020-11-10 14:29:04 +00:00 committed by GitHub
commit a16b0674ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -146,7 +146,12 @@ export class RoomViewModel extends ViewModel {
async _sendMessage(message) { async _sendMessage(message) {
if (message) { if (message) {
try { try {
await this._room.sendEvent("m.room.message", {msgtype: "m.text", body: message}); let msgtype = "m.text";
if (message.startsWith("/me")) {
message = message.substr(3).trim();
msgtype = "m.emote";
}
await this._room.sendEvent("m.room.message", {msgtype, body: message});
} catch (err) { } catch (err) {
console.error(`room.sendMessage(): ${err.message}:\n${err.stack}`); console.error(`room.sendMessage(): ${err.message}:\n${err.stack}`);
this._sendError = err; this._sendError = err;

View file

@ -21,7 +21,7 @@ export class TextTile extends MessageTile {
const content = this._getContent(); const content = this._getContent();
const body = content && content.body; const body = content && content.body;
if (content.msgtype === "m.emote") { if (content.msgtype === "m.emote") {
return `* ${this._entry.sender} ${body}`; return `* ${this.displayName} ${body}`;
} else { } else {
return body; return body;
} }