From 26980e2ad542bcf290640bee3af50d89b585b303 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 19 Dec 2019 15:26:04 +0000 Subject: [PATCH 1/2] apply unhomoglyph when filtering room list to fuzzify it --- src/components/views/rooms/RoomList.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 80a03e7a73..fb1643b8dd 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -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'); @@ -588,11 +589,17 @@ 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; + } + const lcRoomName = room.name ? utils.removeHiddenChars(room.name).toLowerCase() : ""; + return lcRoomName.includes(fuzzyFilter); + }); }, _handleCollapsedState: function(key, collapsed) { From e54429680be928e27815bf11761ea68950147b0b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 19 Dec 2019 15:28:11 +0000 Subject: [PATCH 2/2] tidy up --- src/components/views/rooms/RoomList.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index fb1643b8dd..152ce5105e 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -597,8 +597,7 @@ module.exports = createReactClass({ 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); + return room.name ? utils.removeHiddenChars(room.name).toLowerCase().includes(fuzzyFilter) : false; }); },