Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 356e4bc

Browse files
authored
Merge pull request #5785 from matrix-org/gsouquet-failed-invites
2 parents 80013a2 + 510f08e commit 356e4bc

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

src/components/views/dialogs/InviteDialog.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
673673
console.error(err);
674674
this.setState({
675675
busy: false,
676-
errorText: _t("We couldn't create your DM. Please check the users you want to invite and try again."),
676+
errorText: _t("We couldn't create your DM."),
677677
});
678678
});
679679
};
@@ -886,19 +886,21 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
886886
};
887887

888888
_toggleMember = (member: Member) => {
889-
let filterText = this.state.filterText;
890-
const targets = this.state.targets.map(t => t); // cheap clone for mutation
891-
const idx = targets.indexOf(member);
892-
if (idx >= 0) {
893-
targets.splice(idx, 1);
894-
} else {
895-
targets.push(member);
896-
filterText = ""; // clear the filter when the user accepts a suggestion
897-
}
898-
this.setState({targets, filterText});
889+
if (!this.state.busy) {
890+
let filterText = this.state.filterText;
891+
const targets = this.state.targets.map(t => t); // cheap clone for mutation
892+
const idx = targets.indexOf(member);
893+
if (idx >= 0) {
894+
targets.splice(idx, 1);
895+
} else {
896+
targets.push(member);
897+
filterText = ""; // clear the filter when the user accepts a suggestion
898+
}
899+
this.setState({targets, filterText});
899900

900-
if (this._editorRef && this._editorRef.current) {
901-
this._editorRef.current.focus();
901+
if (this._editorRef && this._editorRef.current) {
902+
this._editorRef.current.focus();
903+
}
902904
}
903905
};
904906

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@
21872187
"Click the button below to confirm your identity.": "Click the button below to confirm your identity.",
21882188
"Invite by email": "Invite by email",
21892189
"Failed to invite the following users to chat: %(csvUsers)s": "Failed to invite the following users to chat: %(csvUsers)s",
2190-
"We couldn't create your DM. Please check the users you want to invite and try again.": "We couldn't create your DM. Please check the users you want to invite and try again.",
2190+
"We couldn't create your DM.": "We couldn't create your DM.",
21912191
"Something went wrong trying to invite the users.": "Something went wrong trying to invite the users.",
21922192
"We couldn't invite those users. Please check the users you want to invite and try again.": "We couldn't invite those users. Please check the users you want to invite and try again.",
21932193
"A call can only be transferred to a single user.": "A call can only be transferred to a single user.",

src/utils/MultiInviter.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,10 @@ export default class MultiInviter {
111111
}
112112

113113
if (!ignoreProfile && SettingsStore.getValue("promptBeforeInviteUnknownUsers", this.roomId)) {
114-
try {
115-
const profile = await MatrixClientPeg.get().getProfileInfo(addr);
116-
if (!profile) {
117-
// noinspection ExceptionCaughtLocallyJS
118-
throw new Error("User has no profile");
119-
}
120-
} catch (e) {
121-
throw {
122-
errcode: "RIOT.USER_NOT_FOUND",
123-
error: "User does not have a profile or does not exist."
124-
};
114+
const profile = await MatrixClientPeg.get().getProfileInfo(addr);
115+
if (!profile) {
116+
// noinspection ExceptionCaughtLocallyJS
117+
throw new Error("User has no profile");
125118
}
126119
}
127120

@@ -171,7 +164,7 @@ export default class MultiInviter {
171164
this._doInvite(address, ignoreProfile).then(resolve, reject);
172165
}, 5000);
173166
return;
174-
} else if (['M_NOT_FOUND', 'M_USER_NOT_FOUND', 'RIOT.USER_NOT_FOUND'].includes(err.errcode)) {
167+
} else if (['M_NOT_FOUND', 'M_USER_NOT_FOUND'].includes(err.errcode)) {
175168
errorText = _t("User %(user_id)s does not exist", {user_id: address});
176169
} else if (err.errcode === 'M_PROFILE_UNDISCLOSED') {
177170
errorText = _t("User %(user_id)s may or may not exist", {user_id: address});
@@ -212,7 +205,7 @@ export default class MultiInviter {
212205
if (Object.keys(this.errors).length > 0 && !this.groupId) {
213206
// There were problems inviting some people - see if we can invite them
214207
// without caring if they exist or not.
215-
const unknownProfileErrors = ['M_NOT_FOUND', 'M_USER_NOT_FOUND', 'M_PROFILE_UNDISCLOSED', 'M_PROFILE_NOT_FOUND', 'RIOT.USER_NOT_FOUND'];
208+
const unknownProfileErrors = ['M_NOT_FOUND', 'M_USER_NOT_FOUND', 'M_PROFILE_UNDISCLOSED', 'M_PROFILE_NOT_FOUND'];
216209
const unknownProfileUsers = Object.keys(this.errors).filter(a => unknownProfileErrors.includes(this.errors[a].errcode));
217210

218211
if (unknownProfileUsers.length > 0) {
@@ -228,7 +221,7 @@ export default class MultiInviter {
228221

229222
const AskInviteAnywayDialog = sdk.getComponent("dialogs.AskInviteAnywayDialog");
230223
console.log("Showing failed to invite dialog...");
231-
Modal.createTrackedDialog('Failed to invite the following users to the room', '', AskInviteAnywayDialog, {
224+
Modal.createTrackedDialog('Failed to invite', '', AskInviteAnywayDialog, {
232225
unknownProfileUsers: unknownProfileUsers.map(u => {return {userId: u, errorText: this.errors[u].errorText};}),
233226
onInviteAnyways: () => inviteUnknowns(),
234227
onGiveUp: () => {

0 commit comments

Comments
 (0)