Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings_profile_fields: Filter out existing external accounts options.

Niloth Pd2fcb895e726
diff --git a/web/src/settings_profile_fields.ts b/web/src/settings_profile_fields.ts
index 1f785414d18..4b08375f486 100644
--- a/web/src/settings_profile_fields.ts
+++ b/web/src/settings_profile_fields.ts
@@ -50,10 +50,25 @@ function setup_external_accounts_dropdown_widget(): void {
};
function get_options_for_external_accounts_dropdown_widget(): Option[] {
+ const existing_default_external_accounts_fields = new Set(
+ realm.custom_profile_fields
+ .filter(
+ (field) => field.type === realm.custom_profile_field_types.EXTERNAL_ACCOUNT.id,
+ )
+ .map((field) =>
+ settings_components.external_account_field_schema.parse(
+ JSON.parse(field.field_data),
+ ),
+ )
+ .filter((fieldData) => fieldData.subtype && fieldData.subtype !== "custom")
+ .map((fieldData) => fieldData.subtype),
+ );
+
const options = [
custom_option,
...Object.entries(realm.realm_default_external_accounts)
.toSorted(([, a], [, b]) => util.strcmp(a.text, b.text))
+ .filter(([key]) => !existing_default_external_accounts_fields.has(key))
.map(([key, account]) => ({
name: account.text,
unique_id: key,