Finals checks about https://github.com/vector-im/hydrogen-web/pull/809#pullrequestreview-1053501341
- joined the processJoinRoom and joinRoom methods; - fixed some precisions miss; - removed some useless code; - change the error message height from absolute (40px) to relative (auto)
This commit is contained in:
parent
176caf340f
commit
3c64f7d49b
2 changed files with 10 additions and 21 deletions
|
@ -199,40 +199,30 @@ export class RoomViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
async joinRoom(roomName) {
|
||||
}
|
||||
|
||||
async _processCommandJoin(roomName) {
|
||||
try {
|
||||
const roomId = await this._options.client.session.joinRoom(roomName);
|
||||
const roomStatusObserver = await this._options.client.session.observeRoomStatus(roomId);
|
||||
await roomStatusObserver.waitFor(status => status === RoomStatus.Joined);
|
||||
this.navigation.push("room", roomId);
|
||||
return true;
|
||||
} catch (exc) {
|
||||
if ((exc.statusCode ?? exc.status) === 400) {
|
||||
return `'${roomName}' was not legal room ID or room alias`;
|
||||
exc = new Error(`/join : '${roomName}' was not legal room ID or room alias`);
|
||||
} else if ((exc.statusCode ?? exc.status) === 404 || (exc.statusCode ?? exc.status) === 502 || exc.message == "Internal Server Error") {
|
||||
return `room '${roomName}' not found`;
|
||||
exc = new Error(`/join : room '${roomName}' not found`);
|
||||
} else if ((exc.statusCode ?? exc.status) === 403) {
|
||||
return `you're not invited to join '${roomName}'`;
|
||||
} else {
|
||||
return exc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
exc = new Error(`/join : you're not invited to join '${roomName}'`);
|
||||
}
|
||||
this._sendError = exc;
|
||||
this._timelineError = null;
|
||||
this.emitChange("error");
|
||||
}
|
||||
}
|
||||
|
||||
async _processCommand (message) {
|
||||
let msgtype = undefined;
|
||||
let msgtype;
|
||||
const [commandName, ...args] = message.substring(1).split(" ");
|
||||
switch (commandName) {
|
||||
case "me":
|
||||
|
@ -269,7 +259,6 @@ export class RoomViewModel extends ViewModel {
|
|||
this._sendError = new Error(`no command name "${commandName}". To send the message instead of executing, please type "/${message}"`);
|
||||
this._timelineError = null;
|
||||
this.emitChange("error");
|
||||
msgtype = undefined;
|
||||
message = undefined;
|
||||
}
|
||||
return {type: msgtype, message: message};
|
||||
|
|
|
@ -539,7 +539,7 @@ a {
|
|||
}
|
||||
|
||||
.RoomView_error:not(:empty) {
|
||||
height : 40px;
|
||||
height : auto;
|
||||
padding-top : 20px;
|
||||
padding-bottom : 20px;
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ a {
|
|||
content:"\274c";
|
||||
position : absolute;
|
||||
top : 15px;
|
||||
left: 10px;
|
||||
left: 9px;
|
||||
width : 20px;
|
||||
height : 10px;
|
||||
font-size : 10px;
|
||||
|
|
Reference in a new issue