Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3754 from matrix-org/t3chguy/fuzzy_filter_room_list
Browse files Browse the repository at this point in the history
apply unhomoglyph when filtering room list to fuzzify it
  • Loading branch information
t3chguy authored Dec 19, 2019
2 parents f3802bf + e544296 commit ba2078e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/views/rooms/RoomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import React from "react";
import ReactDOM from "react-dom";
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import utils from "matrix-js-sdk/lib/utils";
import { _t } from '../../../languageHandler';
const MatrixClientPeg = require("../../../MatrixClientPeg");
const CallHandler = require('../../../CallHandler');
Expand Down Expand Up @@ -588,11 +589,16 @@ module.exports = createReactClass({

_applySearchFilter: function(list, filter) {
if (filter === "") return list;
const fuzzyFilter = utils.removeHiddenChars(filter).toLowerCase();
const lcFilter = filter.toLowerCase();
// case insensitive if room name includes 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)) ||
(filter[0] === '#' && room.getAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter))));
return list.filter((room) => {
if (filter[0] === "#" && room.getAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter))) {
return true;
}
return room.name ? utils.removeHiddenChars(room.name).toLowerCase().includes(fuzzyFilter) : false;
});
},

_handleCollapsedState: function(key, collapsed) {
Expand Down

0 comments on commit ba2078e

Please sign in to comment.