From a230354dbec8b3b1d22210c80d9e6de670faa7f9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 27 Mar 2017 16:40:01 +0100 Subject: [PATCH 1/3] Fix bug where you can't invite a valid address Always show the entered text as an option if it's a valid address, otherwise there's no way to invite an address that is valid and also returns other mxids in the search results. Fixes https://github.com/vector-im/riot-web/issues/3496 --- .../views/dialogs/ChatInviteDialog.js | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index f958b8887c..f78752955b 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -30,15 +30,6 @@ import Fuse from 'fuse.js'; const TRUNCATE_QUERY_LIST = 40; -/* - * Escapes a string so it can be used in a RegExp - * Basically just replaces: \ ^ $ * + ? . ( ) | { } [ ] - * From http://stackoverflow.com/a/6969486 - */ -function escapeRegExp(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); -} - module.exports = React.createClass({ displayName: "ChatInviteDialog", propTypes: { @@ -220,20 +211,19 @@ module.exports = React.createClass({ } }); - // If the query isn't a user we know about, but is a - // valid address, add an entry for that - if (queryList.length == 0) { - const addrType = getAddressType(query); - if (addrType !== null) { - queryList[0] = { - addressType: addrType, - address: query, - isKnown: false, - }; - if (this._cancelThreepidLookup) this._cancelThreepidLookup(); - if (addrType == 'email') { - this._lookupThreepid(addrType, query).done(); - } + // If the query is a valid address, add an entry for that + // This i simportant, otherwise there's no way to invite + // a perfectly valid address if there are close matches. + const addrType = getAddressType(query); + if (addrType !== null) { + queryList.unshift({ + addressType: addrType, + address: query, + isKnown: false, + }); + if (this._cancelThreepidLookup) this._cancelThreepidLookup(); + if (addrType == 'email') { + this._lookupThreepid(addrType, query).done(); } } } From 9125c1b2ccee1854309e6a7859b9f83cfe8c4662 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 27 Mar 2017 17:00:05 +0100 Subject: [PATCH 2/3] I can't type --- src/components/views/dialogs/ChatInviteDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index f78752955b..ad20ebaa18 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -212,7 +212,7 @@ module.exports = React.createClass({ }); // If the query is a valid address, add an entry for that - // This i simportant, otherwise there's no way to invite + // This is simportant, otherwise there's no way to invite // a perfectly valid address if there are close matches. const addrType = getAddressType(query); if (addrType !== null) { From db3339de33eaaae2cd8a49e6d0979c3c332e2975 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 27 Mar 2017 17:03:59 +0100 Subject: [PATCH 3/3] I still can't type --- src/components/views/dialogs/ChatInviteDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index ad20ebaa18..16f756a773 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -212,7 +212,7 @@ module.exports = React.createClass({ }); // If the query is a valid address, add an entry for that - // This is simportant, otherwise there's no way to invite + // This is important, otherwise there's no way to invite // a perfectly valid address if there are close matches. const addrType = getAddressType(query); if (addrType !== null) {