fix: Allow querying by email address in share popover
This commit is contained in:
@@ -426,15 +426,22 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(item.title || "").toLowerCase().includes(searchInput) ||
|
(item.title || "").toLocaleLowerCase().includes(searchInput) ||
|
||||||
(item.keywords || "").toLowerCase().includes(searchInput)
|
(item.keywords || "").toLocaleLowerCase().includes(searchInput)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return filterExcessSeparators(
|
return filterExcessSeparators(
|
||||||
filtered.sort((item) =>
|
filtered
|
||||||
searchInput && item.title ? commandScore(item.title, searchInput) : 0
|
.map((item) => ({
|
||||||
)
|
item,
|
||||||
|
score:
|
||||||
|
searchInput && item.title
|
||||||
|
? commandScore(item.title, searchInput)
|
||||||
|
: 0,
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.score - a.score)
|
||||||
|
.map(({ item }) => item)
|
||||||
);
|
);
|
||||||
}, [commands, props]);
|
}, [commands, props]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import commandScore from "command-score";
|
||||||
import invariant from "invariant";
|
import invariant from "invariant";
|
||||||
import deburr from "lodash/deburr";
|
import deburr from "lodash/deburr";
|
||||||
import differenceWith from "lodash/differenceWith";
|
import differenceWith from "lodash/differenceWith";
|
||||||
@@ -331,11 +332,20 @@ export default class UsersStore extends Store<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function queriedUsers(users: User[], query?: string) {
|
function queriedUsers(users: User[], query?: string) {
|
||||||
return query
|
const normalizedQuery = deburr((query || "").toLocaleLowerCase());
|
||||||
? filter(users, (user) =>
|
|
||||||
deburr(user.name.toLocaleLowerCase()).includes(
|
return normalizedQuery
|
||||||
deburr(query.toLocaleLowerCase())
|
? filter(
|
||||||
)
|
users,
|
||||||
|
(user) =>
|
||||||
|
deburr(user.name.toLocaleLowerCase()).includes(normalizedQuery) ||
|
||||||
|
user.email?.includes(normalizedQuery)
|
||||||
)
|
)
|
||||||
|
.map((user) => ({
|
||||||
|
user,
|
||||||
|
score: commandScore(user.name, normalizedQuery),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.score - a.score)
|
||||||
|
.map(({ user }) => user)
|
||||||
: users;
|
: users;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user