Some fixes :

- fixed a pretty syntax miss (a !== b);
 - fixed a type error : replaced "msgtype" by "type" when instantied the "messinfo" variable;
 - some indentation fixes
This commit is contained in:
Kaki In 2022-07-27 16:36:58 +02:00
parent ab64ce02b2
commit a40bb59dc0

View File

@ -230,7 +230,7 @@ export class RoomViewModel extends ViewModel {
if (args.length == 1) { if (args.length == 1) {
const roomName = args[0]; const roomName = args[0];
const exc = await this.joinRoom(roomName); const exc = await this.joinRoom(roomName);
if (exc!==true) { if (exc !== true) {
if (exc && exc.stack && exc.message) { if (exc && exc.stack && exc.message) {
this._sendError = exc; this._sendError = exc;
} else { } else {
@ -273,21 +273,21 @@ export class RoomViewModel extends ViewModel {
async _sendMessage(message, replyingTo) { async _sendMessage(message, replyingTo) {
if (!this._room.isArchived && message) { if (!this._room.isArchived && message) {
let messinfo = {msgtype : "m.text", message : message}; let messinfo = {type : "m.text", message : message};
if (message.startsWith("//")) { if (message.startsWith("//")) {
messinfo.message = message.substring(1).trim(); messinfo.message = message.substring(1).trim();
} else if (message.startsWith("/")) { } else if (message.startsWith("/")) {
messinfo = await this._processCommand(message); messinfo = await this._processCommand(message);
} }
try { try {
const msgtype = messinfo.type; const msgtype = messinfo.type;
const message = messinfo.message; const message = messinfo.message;
if (msgtype && message) { if (msgtype && message) {
if (replyingTo) { if (replyingTo) {
await replyingTo.reply(msgtype, message); await replyingTo.reply(msgtype, message);
} else { } else {
await this._room.sendEvent("m.room.message", {msgtype, body: message}); 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}`);