show send errors in UI

This commit is contained in:
Bruno Windels 2019-09-15 12:23:26 +02:00
parent 5a90b4673b
commit f7f9129b8b
2 changed files with 13 additions and 3 deletions

View File

@ -66,7 +66,16 @@ export default class RoomViewModel extends EventEmitter {
sendMessage(message) {
if (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;
}
}

View File

@ -16,8 +16,9 @@ export default class MessageComposer extends TemplateView {
_onKeyDown(event) {
if (event.key === "Enter") {
this.viewModel.sendMessage(this._input.value);
if (this.viewModel.sendMessage(this._input.value)) {
this._input.value = "";
}
}
}
}