From d8baad31da17a4f9d493c4dc073627fff6038d60 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 29 Jul 2020 16:51:37 +0200 Subject: [PATCH 1/3] provide nicer error for no known servers error when accepting an invite --- src/i18n/strings/en_EN.json | 2 ++ src/stores/RoomViewStore.js | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 18e2da9a31..ad33823c96 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -423,6 +423,8 @@ "Upgrade your %(brand)s": "Upgrade your %(brand)s", "A new version of %(brand)s is available!": "A new version of %(brand)s is available!", "Guest": "Guest", + "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.", "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.", diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index 6e5007895c..4f560e1fab 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -265,10 +265,20 @@ class RoomViewStore extends Store { }); let msg = err.message ? err.message : JSON.stringify(err); console.log("Failed to join room:", msg); - if (err.name === "ConnectionError") { + 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."); + } + } + } else 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 =
{_t("Sorry, your homeserver is too old to participate in this room.")}
{_t("Please contact your homeserver administrator.")} @@ -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, From bb685cd37a50cbafe644c25842228b02458bef0f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 30 Jul 2020 10:33:36 +0200 Subject: [PATCH 2/3] change message priority --- src/stores/RoomViewStore.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index 4f560e1fab..3c37a31174 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -265,7 +265,14 @@ class RoomViewStore extends Store { }); let msg = err.message ? err.message : JSON.stringify(err); console.log("Failed to join room:", msg); - if (err.httpStatus === 404) { + if (err.name === "ConnectionError") { + msg = _t("There was an error joining the room"); + } else if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') { + msg =
+ {_t("Sorry, your homeserver is too old to participate in this room.")}
+ {_t("Please contact your homeserver administrator.")} +
; + } else if (err.httpStatus === 404) { const invitingUserId = this._getInvitingUserId(this._state.roomId); // only provide a better error message for invites if (invitingUserId) { @@ -276,13 +283,6 @@ class RoomViewStore extends Store { msg = _t("The person who invited you already left the room, or their server is offline."); } } - } else if (err.name === "ConnectionError") { - msg = _t("There was an error joining the room"); - } else if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') { - msg =
- {_t("Sorry, your homeserver is too old to participate in this room.")}
- {_t("Please contact your homeserver administrator.")} -
; } const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Failed to join room', '', ErrorDialog, { From a281c617beb24293b40e8e65f5012ee5266f8e91 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 30 Jul 2020 10:42:46 +0200 Subject: [PATCH 3/3] string order changed --- src/i18n/strings/en_EN.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ad33823c96..644cd03daf 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -423,11 +423,11 @@ "Upgrade your %(brand)s": "Upgrade your %(brand)s", "A new version of %(brand)s is available!": "A new version of %(brand)s is available!", "Guest": "Guest", - "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.", "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",