From bc0281ebddf21697d4f58cfec74e720a87d24912 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 16 Jun 2020 08:36:10 -0600 Subject: [PATCH] Match fuzzy filtering a bit more reliably in the new room list Fixes https://github.com/vector-im/riot-web/issues/14054 --- src/stores/room-list/filters/NameFilterCondition.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/stores/room-list/filters/NameFilterCondition.ts b/src/stores/room-list/filters/NameFilterCondition.ts index 7b6ed76e79..4ac5b68596 100644 --- a/src/stores/room-list/filters/NameFilterCondition.ts +++ b/src/stores/room-list/filters/NameFilterCondition.ts @@ -56,6 +56,14 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio return true; } } - return room.name && removeHiddenChars(room.name).toLowerCase().includes(lcFilter); + + if (!room.name) return false; // should realisitically not happen: the js-sdk always calculates a name + + // Note: we have to match the filter with the removeHiddenChars() room name because the + // function strips spaces and other characters (M becomes RN for example, in lowercase). + // We also doubly convert to lowercase to work around oddities of the library. + const noSecretsFilter = removeHiddenChars(lcFilter).toLowerCase(); + const noSecretsName = removeHiddenChars(room.name.toLowerCase()).toLowerCase(); + return noSecretsName.includes(noSecretsFilter); } }