apply unhomoglyph when filtering room list to fuzzify it
This commit is contained in:
parent
29523000dc
commit
26980e2ad5
1 changed files with 9 additions and 2 deletions
|
@ -22,6 +22,7 @@ import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import createReactClass from 'create-react-class';
|
import createReactClass from 'create-react-class';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import utils from "matrix-js-sdk/lib/utils";
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
const MatrixClientPeg = require("../../../MatrixClientPeg");
|
const MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||||
const CallHandler = require('../../../CallHandler');
|
const CallHandler = require('../../../CallHandler');
|
||||||
|
@ -588,11 +589,17 @@ module.exports = createReactClass({
|
||||||
|
|
||||||
_applySearchFilter: function(list, filter) {
|
_applySearchFilter: function(list, filter) {
|
||||||
if (filter === "") return list;
|
if (filter === "") return list;
|
||||||
|
const fuzzyFilter = utils.removeHiddenChars(filter).toLowerCase();
|
||||||
const lcFilter = filter.toLowerCase();
|
const lcFilter = filter.toLowerCase();
|
||||||
// case insensitive if room name includes filter,
|
// case insensitive if room name includes filter,
|
||||||
// or if starts with `#` and one of room's aliases starts with filter
|
// or if starts with `#` and one of room's aliases starts with filter
|
||||||
return list.filter((room) => (room.name && room.name.toLowerCase().includes(lcFilter)) ||
|
return list.filter((room) => {
|
||||||
(filter[0] === '#' && room.getAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter))));
|
if (filter[0] === "#" && room.getAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const lcRoomName = room.name ? utils.removeHiddenChars(room.name).toLowerCase() : "";
|
||||||
|
return lcRoomName.includes(fuzzyFilter);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleCollapsedState: function(key, collapsed) {
|
_handleCollapsedState: function(key, collapsed) {
|
||||||
|
|
Loading…
Reference in a new issue