Merge pull request #4769 from matrix-org/travis/room-list/fuzzy-filter

Match fuzzy filtering a bit more reliably in the new room list
pull/21833/head
Travis Ralston 2020-06-17 07:15:36 -06:00 committed by GitHub
commit 3bdf3be3f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -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);
}
}