diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 23875e20..09de2b8b 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -66,7 +66,16 @@ export default class RoomViewModel extends EventEmitter { sendMessage(message) { if (message) { - this._room.sendEvent("m.room.message", {msgtype: "m.text", body: message}); + try { + this._room.sendEvent("m.room.message", {msgtype: "m.text", body: message}); + } catch (err) { + console.error(`room.sendMessage(): ${err.message}:\n${err.stack}`); + this._timelineError = err; + this.emit("change", "error"); + return false; + } + return true; } + return false; } } diff --git a/src/ui/web/session/room/MessageComposer.js b/src/ui/web/session/room/MessageComposer.js index a4fb3715..79e2fd5e 100644 --- a/src/ui/web/session/room/MessageComposer.js +++ b/src/ui/web/session/room/MessageComposer.js @@ -16,8 +16,9 @@ export default class MessageComposer extends TemplateView { _onKeyDown(event) { if (event.key === "Enter") { - this.viewModel.sendMessage(this._input.value); - this._input.value = ""; + if (this.viewModel.sendMessage(this._input.value)) { + this._input.value = ""; + } } } }