From a4f610ad3fa93b9e3a5986d84fd11b4ec76cc8b5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 10 Nov 2020 15:13:31 +0100 Subject: [PATCH] support emotes --- src/domain/session/room/RoomViewModel.js | 7 ++++++- src/domain/session/room/timeline/tiles/TextTile.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 8811625a..e2a092ae 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -146,7 +146,12 @@ export class RoomViewModel extends ViewModel { async _sendMessage(message) { if (message) { 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) { console.error(`room.sendMessage(): ${err.message}:\n${err.stack}`); this._sendError = err; diff --git a/src/domain/session/room/timeline/tiles/TextTile.js b/src/domain/session/room/timeline/tiles/TextTile.js index 3009e15e..8f5265d4 100644 --- a/src/domain/session/room/timeline/tiles/TextTile.js +++ b/src/domain/session/room/timeline/tiles/TextTile.js @@ -21,7 +21,7 @@ export class TextTile extends MessageTile { const content = this._getContent(); const body = content && content.body; if (content.msgtype === "m.emote") { - return `* ${this._entry.sender} ${body}`; + return `* ${this.displayName} ${body}`; } else { return body; }