mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Support any alias not just first
This commit is contained in:
parent
655010844a
commit
edb2026780
2 changed files with 8 additions and 3 deletions
|
@ -21,7 +21,7 @@ import {removeHiddenChars} from "matrix-js-sdk/src/utils";
|
||||||
|
|
||||||
interface IOptions<T extends {}> {
|
interface IOptions<T extends {}> {
|
||||||
keys: Array<string | keyof T>;
|
keys: Array<string | keyof T>;
|
||||||
funcs?: Array<(T) => string>;
|
funcs?: Array<(T) => string | string[]>;
|
||||||
shouldMatchWordsOnly?: boolean;
|
shouldMatchWordsOnly?: boolean;
|
||||||
// whether to apply unhomoglyph and strip diacritics to fuzz up the search. Defaults to true
|
// whether to apply unhomoglyph and strip diacritics to fuzz up the search. Defaults to true
|
||||||
fuzzy?: boolean;
|
fuzzy?: boolean;
|
||||||
|
@ -69,7 +69,12 @@ export default class QueryMatcher<T extends Object> {
|
||||||
|
|
||||||
if (this._options.funcs) {
|
if (this._options.funcs) {
|
||||||
for (const f of 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) {
|
if (lcQuery) {
|
||||||
const matcher = new QueryMatcher<Room>(visibleRooms, {
|
const matcher = new QueryMatcher<Room>(visibleRooms, {
|
||||||
keys: ["name"],
|
keys: ["name"],
|
||||||
funcs: [r => r.getCanonicalAlias() ?? r.getAltAliases()?.[0]],
|
funcs: [r => [r.getCanonicalAlias(), ...r.getAltAliases()].filter(Boolean)],
|
||||||
shouldMatchWordsOnly: false,
|
shouldMatchWordsOnly: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue