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 (
|
||||
(item.title || "").toLowerCase().includes(searchInput) ||
|
||||
(item.keywords || "").toLowerCase().includes(searchInput)
|
||||
(item.title || "").toLocaleLowerCase().includes(searchInput) ||
|
||||
(item.keywords || "").toLocaleLowerCase().includes(searchInput)
|
||||
);
|
||||
});
|
||||
|
||||
return filterExcessSeparators(
|
||||
filtered.sort((item) =>
|
||||
searchInput && item.title ? commandScore(item.title, searchInput) : 0
|
||||
)
|
||||
filtered
|
||||
.map((item) => ({
|
||||
item,
|
||||
score:
|
||||
searchInput && item.title
|
||||
? commandScore(item.title, searchInput)
|
||||
: 0,
|
||||
}))
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.map(({ item }) => item)
|
||||
);
|
||||
}, [commands, props]);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import commandScore from "command-score";
|
||||
import invariant from "invariant";
|
||||
import deburr from "lodash/deburr";
|
||||
import differenceWith from "lodash/differenceWith";
|
||||
@@ -331,11 +332,20 @@ export default class UsersStore extends Store<User> {
|
||||
}
|
||||
|
||||
function queriedUsers(users: User[], query?: string) {
|
||||
return query
|
||||
? filter(users, (user) =>
|
||||
deburr(user.name.toLocaleLowerCase()).includes(
|
||||
deburr(query.toLocaleLowerCase())
|
||||
)
|
||||
const normalizedQuery = deburr((query || "").toLocaleLowerCase());
|
||||
|
||||
return normalizedQuery
|
||||
? 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user