From 1f6f9ca9838b830f33a8e364c21e405f97eda434 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Tue, 23 Mar 2021 18:24:05 +0000 Subject: [PATCH 1/4] Only show the ask anyway modal for explicit user lookup failures --- src/utils/MultiInviter.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/utils/MultiInviter.js b/src/utils/MultiInviter.js index 63d3942b37..05fa06ee14 100644 --- a/src/utils/MultiInviter.js +++ b/src/utils/MultiInviter.js @@ -111,17 +111,10 @@ export default class MultiInviter { } if (!ignoreProfile && SettingsStore.getValue("promptBeforeInviteUnknownUsers", this.roomId)) { - try { - const profile = await MatrixClientPeg.get().getProfileInfo(addr); - if (!profile) { - // noinspection ExceptionCaughtLocallyJS - throw new Error("User has no profile"); - } - } catch (e) { - throw { - errcode: "RIOT.USER_NOT_FOUND", - error: "User does not have a profile or does not exist." - }; + const profile = await MatrixClientPeg.get().getProfileInfo(addr); + if (!profile) { + // noinspection ExceptionCaughtLocallyJS + throw new Error("User has no profile"); } } From b8692bdf175ce27e78bfb27102ef61445b947503 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Tue, 23 Mar 2021 18:25:03 +0000 Subject: [PATCH 2/4] Prevent state to be toggled whilst a request is pending --- src/components/views/dialogs/InviteDialog.tsx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx index de0b5b237b..4ea53349bd 100644 --- a/src/components/views/dialogs/InviteDialog.tsx +++ b/src/components/views/dialogs/InviteDialog.tsx @@ -886,19 +886,21 @@ export default class InviteDialog extends React.PureComponent { - let filterText = this.state.filterText; - const targets = this.state.targets.map(t => t); // cheap clone for mutation - const idx = targets.indexOf(member); - if (idx >= 0) { - targets.splice(idx, 1); - } else { - targets.push(member); - filterText = ""; // clear the filter when the user accepts a suggestion - } - this.setState({targets, filterText}); + if (!this.state.busy) { + let filterText = this.state.filterText; + const targets = this.state.targets.map(t => t); // cheap clone for mutation + const idx = targets.indexOf(member); + if (idx >= 0) { + targets.splice(idx, 1); + } else { + targets.push(member); + filterText = ""; // clear the filter when the user accepts a suggestion + } + this.setState({targets, filterText}); - if (this._editorRef && this._editorRef.current) { - this._editorRef.current.focus(); + if (this._editorRef && this._editorRef.current) { + this._editorRef.current.focus(); + } } }; From d836ca19d86fc65c4bea99a50de37f0958b036af Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Wed, 24 Mar 2021 08:58:08 +0000 Subject: [PATCH 3/4] remove references to disused RIOT.USER_NOT_FOUND error code --- src/utils/MultiInviter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/MultiInviter.js b/src/utils/MultiInviter.js index 05fa06ee14..3d3a5f4137 100644 --- a/src/utils/MultiInviter.js +++ b/src/utils/MultiInviter.js @@ -164,7 +164,7 @@ export default class MultiInviter { this._doInvite(address, ignoreProfile).then(resolve, reject); }, 5000); return; - } else if (['M_NOT_FOUND', 'M_USER_NOT_FOUND', 'RIOT.USER_NOT_FOUND'].includes(err.errcode)) { + } else if (['M_NOT_FOUND', 'M_USER_NOT_FOUND'].includes(err.errcode)) { errorText = _t("User %(user_id)s does not exist", {user_id: address}); } else if (err.errcode === 'M_PROFILE_UNDISCLOSED') { errorText = _t("User %(user_id)s may or may not exist", {user_id: address}); @@ -205,7 +205,7 @@ export default class MultiInviter { if (Object.keys(this.errors).length > 0 && !this.groupId) { // There were problems inviting some people - see if we can invite them // without caring if they exist or not. - const unknownProfileErrors = ['M_NOT_FOUND', 'M_USER_NOT_FOUND', 'M_PROFILE_UNDISCLOSED', 'M_PROFILE_NOT_FOUND', 'RIOT.USER_NOT_FOUND']; + const unknownProfileErrors = ['M_NOT_FOUND', 'M_USER_NOT_FOUND', 'M_PROFILE_UNDISCLOSED', 'M_PROFILE_NOT_FOUND']; const unknownProfileUsers = Object.keys(this.errors).filter(a => unknownProfileErrors.includes(this.errors[a].errcode)); if (unknownProfileUsers.length > 0) { From 510f08e9f1c923a0dfe3b1fd73ab1fc92af2a772 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Thu, 25 Mar 2021 10:11:52 +0000 Subject: [PATCH 4/4] Update failed invites copy --- src/components/views/dialogs/InviteDialog.tsx | 2 +- src/i18n/strings/en_EN.json | 2 +- src/utils/MultiInviter.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx index 4ea53349bd..8ad262cff9 100644 --- a/src/components/views/dialogs/InviteDialog.tsx +++ b/src/components/views/dialogs/InviteDialog.tsx @@ -673,7 +673,7 @@ export default class InviteDialog extends React.PureComponent {return {userId: u, errorText: this.errors[u].errorText};}), onInviteAnyways: () => inviteUnknowns(), onGiveUp: () => {