From 176caf340fb1ddf53ec411a38f33c5e009bf6b76 Mon Sep 17 00:00:00 2001 From: Kaki In <91763754+Kaki-In@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:42:44 +0200 Subject: [PATCH] Placed the join command outside of the processCommand method --- src/domain/session/room/RoomViewModel.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index a6db142b..74cb3d05 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -218,6 +218,19 @@ export class RoomViewModel extends ViewModel { } } + async _processCommandJoin(roomName) { + const exc = await this.joinRoom(roomName); + if (exc !== true) { + if (exc && exc.stack && exc.message) { + this._sendError = exc; + } else { + this._sendError = new Error("/join : " + exc); + } + this._timelineError = null; + this.emitChange("error"); + } + } + async _processCommand (message) { let msgtype = undefined; const [commandName, ...args] = message.substring(1).split(" "); @@ -229,16 +242,7 @@ export class RoomViewModel extends ViewModel { case "join": if (args.length == 1) { const roomName = args[0]; - const exc = await this.joinRoom(roomName); - if (exc !== true) { - if (exc && exc.stack && exc.message) { - this._sendError = exc; - } else { - this._sendError = new Error("/join : " + exc); - } - this._timelineError = null; - this.emitChange("error"); - } + await this._processCommandJoin(roomName); } else { this._sendError = new Error("join syntax: /join "); this._timelineError = null;