You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-17 17:42:41 +03:00
Merge pull request #3783 from matrix-org/t3chguy/fuzzy_sort_memberlist
fuzzy-sort MemberList
This commit is contained in:
@@ -32,6 +32,10 @@ const INITIAL_LOAD_NUM_MEMBERS = 30;
|
|||||||
const INITIAL_LOAD_NUM_INVITED = 5;
|
const INITIAL_LOAD_NUM_INVITED = 5;
|
||||||
const SHOW_MORE_INCREMENT = 100;
|
const SHOW_MORE_INCREMENT = 100;
|
||||||
|
|
||||||
|
// 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({
|
module.exports = createReactClass({
|
||||||
displayName: 'MemberList',
|
displayName: 'MemberList',
|
||||||
|
|
||||||
@@ -336,10 +340,13 @@ module.exports = createReactClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fourth by name (alphabetical)
|
// Fourth by name (alphabetical)
|
||||||
const nameA = memberA.name[0] === '@' ? memberA.name.substr(1) : memberA.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;
|
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`);
|
// 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) {
|
onSearchQueryChanged: function(searchQuery) {
|
||||||
|
|||||||
Reference in New Issue
Block a user