From e320f64ba1ed9d6f99138885bcbd68fe2f402e85 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 Dec 2019 19:27:04 +0000 Subject: [PATCH 1/3] fuzzy-sort MemberList --- src/components/views/rooms/MemberList.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 0805c0342c..b874c378d4 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -32,6 +32,9 @@ const INITIAL_LOAD_NUM_MEMBERS = 30; const INITIAL_LOAD_NUM_INVITED = 5; const SHOW_MORE_INCREMENT = 100; +// Regex applied to member names before applying sort, to fuzzy it a little +const SORT_REGEX = /[.?!,;:\-()[\]{}'"&@]+/g; + module.exports = createReactClass({ displayName: 'MemberList', @@ -336,10 +339,13 @@ module.exports = createReactClass({ } // Fourth by name (alphabetical) - const nameA = memberA.name[0] === '@' ? memberA.name.substr(1) : memberA.name; - const nameB = memberB.name[0] === '@' ? memberB.name.substr(1) : memberB.name; + const nameA = (memberA.name[0] === '@' ? memberA.name.substr(1) : memberA.name).replace(SORT_REGEX, ""); + const nameB = (memberB.name[0] === '@' ? memberB.name.substr(1) : memberB.name).replace(SORT_REGEX, ""); // console.log(`Comparing userA_name=${nameA} against userB_name=${nameB} - returning`); - return nameA.localeCompare(nameB); + return nameA.localeCompare(nameB, { + ignorePunctuation: true, + sensitivity: "base", + }); }, onSearchQueryChanged: function(searchQuery) { From ab122889795b5aa864dda67ac1a9b4d99e4555be Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 26 Dec 2019 19:29:25 +0000 Subject: [PATCH 2/3] Add more punctuation to regex --- src/components/views/rooms/MemberList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index b874c378d4..bbb1390611 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -33,7 +33,7 @@ const INITIAL_LOAD_NUM_INVITED = 5; const SHOW_MORE_INCREMENT = 100; // Regex applied to member names before applying sort, to fuzzy it a little -const SORT_REGEX = /[.?!,;:\-()[\]{}'"&@]+/g; +const SORT_REGEX = /[.?!,;:\-()[\]{}'"&@#\\/+_=]+/g; module.exports = createReactClass({ displayName: 'MemberList', From f9e386adaa289e871a6da26ecaf12fc92fea0473 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 27 Dec 2019 17:04:14 +0000 Subject: [PATCH 3/3] Improve SORT_REGEX --- src/components/views/rooms/MemberList.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index bbb1390611..de0a6fe478 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -32,8 +32,9 @@ const INITIAL_LOAD_NUM_MEMBERS = 30; const INITIAL_LOAD_NUM_INVITED = 5; const SHOW_MORE_INCREMENT = 100; -// Regex applied to member names before applying sort, to fuzzy it a little -const SORT_REGEX = /[.?!,;:\-()[\]{}'"&@#\\/+_=]+/g; +// Regex applied to filter our punctuation in member names before applying sort, to fuzzy it a little +// matches all ASCII punctuation: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ +const SORT_REGEX = /[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+/g; module.exports = createReactClass({ displayName: 'MemberList',