mirror of https://github.com/vector-im/riot-web
Support any alias not just first
parent
655010844a
commit
edb2026780
|
@ -21,7 +21,7 @@ import {removeHiddenChars} from "matrix-js-sdk/src/utils";
|
|||
|
||||
interface IOptions<T extends {}> {
|
||||
keys: Array<string | keyof T>;
|
||||
funcs?: Array<(T) => string>;
|
||||
funcs?: Array<(T) => string | string[]>;
|
||||
shouldMatchWordsOnly?: boolean;
|
||||
// whether to apply unhomoglyph and strip diacritics to fuzz up the search. Defaults to true
|
||||
fuzzy?: boolean;
|
||||
|
@ -69,7 +69,12 @@ export default class QueryMatcher<T extends Object> {
|
|||
|
||||
if (this._options.funcs) {
|
||||
for (const f of this._options.funcs) {
|
||||
keyValues.push(f(object));
|
||||
const v = f(object);
|
||||
if (Array.isArray(v)) {
|
||||
keyValues.push(...v);
|
||||
} else {
|
||||
keyValues.push(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ export const AddExistingToSpace: React.FC<IAddExistingToSpaceProps> = ({
|
|||
if (lcQuery) {
|
||||
const matcher = new QueryMatcher<Room>(visibleRooms, {
|
||||
keys: ["name"],
|
||||
funcs: [r => r.getCanonicalAlias() ?? r.getAltAliases()?.[0]],
|
||||
funcs: [r => [r.getCanonicalAlias(), ...r.getAltAliases()].filter(Boolean)],
|
||||
shouldMatchWordsOnly: false,
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue