forked from mystiq/hydrogen-web
show send errors in UI
This commit is contained in:
parent
5a90b4673b
commit
f7f9129b8b
2 changed files with 13 additions and 3 deletions
|
@ -66,7 +66,16 @@ export default class RoomViewModel extends EventEmitter {
|
||||||
|
|
||||||
sendMessage(message) {
|
sendMessage(message) {
|
||||||
if (message) {
|
if (message) {
|
||||||
|
try {
|
||||||
this._room.sendEvent("m.room.message", {msgtype: "m.text", body: message});
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,9 @@ export default class MessageComposer extends TemplateView {
|
||||||
|
|
||||||
_onKeyDown(event) {
|
_onKeyDown(event) {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
this.viewModel.sendMessage(this._input.value);
|
if (this.viewModel.sendMessage(this._input.value)) {
|
||||||
this._input.value = "";
|
this._input.value = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue