mirror of https://github.com/vector-im/riot-web
Merge pull request #5061 from matrix-org/bwindels/noknownserverserror
Provide nicer error for no known servers error when accepting an invitepull/21833/head
commit
0526fcdf44
|
@ -426,6 +426,8 @@
|
|||
"There was an error joining the room": "There was an error joining the room",
|
||||
"Sorry, your homeserver is too old to participate in this room.": "Sorry, your homeserver is too old to participate in this room.",
|
||||
"Please contact your homeserver administrator.": "Please contact your homeserver administrator.",
|
||||
"The person who invited you already left the room.": "The person who invited you already left the room.",
|
||||
"The person who invited you already left the room, or their server is offline.": "The person who invited you already left the room, or their server is offline.",
|
||||
"Failed to join room": "Failed to join room",
|
||||
"You joined the call": "You joined the call",
|
||||
"%(senderName)s joined the call": "%(senderName)s joined the call",
|
||||
|
|
|
@ -267,12 +267,22 @@ class RoomViewStore extends Store {
|
|||
console.log("Failed to join room:", msg);
|
||||
if (err.name === "ConnectionError") {
|
||||
msg = _t("There was an error joining the room");
|
||||
}
|
||||
if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') {
|
||||
} else if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') {
|
||||
msg = <div>
|
||||
{_t("Sorry, your homeserver is too old to participate in this room.")}<br />
|
||||
{_t("Please contact your homeserver administrator.")}
|
||||
</div>;
|
||||
} else if (err.httpStatus === 404) {
|
||||
const invitingUserId = this._getInvitingUserId(this._state.roomId);
|
||||
// only provide a better error message for invites
|
||||
if (invitingUserId) {
|
||||
// if the inviting user is on the same HS, there can only be one cause: they left.
|
||||
if (invitingUserId.endsWith(`:${MatrixClientPeg.get().getDomain()}`)) {
|
||||
msg = _t("The person who invited you already left the room.");
|
||||
} else {
|
||||
msg = _t("The person who invited you already left the room, or their server is offline.");
|
||||
}
|
||||
}
|
||||
}
|
||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||
Modal.createTrackedDialog('Failed to join room', '', ErrorDialog, {
|
||||
|
@ -282,6 +292,16 @@ class RoomViewStore extends Store {
|
|||
});
|
||||
}
|
||||
|
||||
_getInvitingUserId(roomId) {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const room = cli.getRoom(roomId);
|
||||
if (room && room.getMyMembership() === "invite") {
|
||||
const myMember = room.getMember(cli.getUserId());
|
||||
const inviteEvent = myMember ? myMember.events.member : null;
|
||||
return inviteEvent && inviteEvent.getSender();
|
||||
}
|
||||
}
|
||||
|
||||
_joinRoomError(payload) {
|
||||
this._setState({
|
||||
joining: false,
|
||||
|
|
Loading…
Reference in New Issue