mirror of
https://github.com/zulip/zulip.git
synced 2026-07-06 21:18:58 +08:00
user_pill: Avoid unnecessary array allocations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c0c852046d
commit
2e8fdab896
@ -26,16 +26,11 @@ export function create_item_from_email(
|
||||
pill_config?: InputPillConfig | undefined,
|
||||
): InputPillItem<UserPill> | undefined {
|
||||
// For normal Zulip use, we need to validate the email for our realm.
|
||||
const filtered_current_items = current_items.flatMap((item) =>
|
||||
item.type === "user" ? item : [],
|
||||
);
|
||||
const user = people.get_by_email(email);
|
||||
|
||||
if (!user) {
|
||||
if (realm.realm_is_zephyr_mirror_realm) {
|
||||
const existing_emails = filtered_current_items.map((item) => item.email);
|
||||
|
||||
if (existing_emails.includes(email)) {
|
||||
if (current_items.some((item) => item.type === "user" && item.email === email)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -57,9 +52,7 @@ export function create_item_from_email(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const existing_ids = filtered_current_items.map((item) => item.user_id);
|
||||
|
||||
if (existing_ids.includes(user.user_id)) {
|
||||
if (current_items.some((item) => item.type === "user" && item.user_id === user.user_id)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user