Always insert suggestions for user IDs

Fixes https://github.com/vector-im/riot-web/issues/12419
This commit is contained in:
Travis Ralston 2020-02-20 23:01:50 -07:00
parent 00cc253594
commit 62aaa0db9a

View file

@ -630,13 +630,14 @@ export default class InviteDialog extends React.PureComponent {
// While we're here, try and autocomplete a search result for the mxid itself // While we're here, try and autocomplete a search result for the mxid itself
// if there's no matches (and the input looks like a mxid). // if there's no matches (and the input looks like a mxid).
if (term[0] === '@' && term.indexOf(':') > 1 && r.results.length === 0) { if (term[0] === '@' && term.indexOf(':') > 1) {
try { try {
const profile = await MatrixClientPeg.get().getProfileInfo(term); const profile = await MatrixClientPeg.get().getProfileInfo(term);
if (profile) { if (profile) {
// If we have a profile, we have enough information to assume that // If we have a profile, we have enough information to assume that
// the mxid can be invited - add it to the list // the mxid can be invited - add it to the list. We stick it at the
r.results.push({ // top so it is most obviously presented to the user.
r.results.splice(0, 0, {
user_id: term, user_id: term,
display_name: profile['displayname'], display_name: profile['displayname'],
avatar_url: profile['avatar_url'], avatar_url: profile['avatar_url'],
@ -646,8 +647,9 @@ export default class InviteDialog extends React.PureComponent {
console.warn("Non-fatal error trying to make an invite for a user ID"); console.warn("Non-fatal error trying to make an invite for a user ID");
console.warn(e); console.warn(e);
// Add a result anyways, just without a profile // Add a result anyways, just without a profile. We stick it at the
r.results.push({ // top so it is most obviously presented to the user.
r.results.splice(0, 0,{
user_id: term, user_id: term,
display_name: term, display_name: term,
avatar_url: null, avatar_url: null,