Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_profile: Pass undefined instead of an empty object.
afeefuddinfd72b4451a23
diff --git a/web/src/user_card_popover.js b/web/src/user_card_popover.jsindex fb2ca593c28..f1b73c699cc 100644--- a/web/src/user_card_popover.js+++ b/web/src/user_card_popover.js@@ -229,7 +229,7 @@ function get_user_card_popover_data(// Filtering out only those profile fields that can be display in the popover and are not empty.const field_types = realm.custom_profile_field_types;const display_profile_fields = realm.custom_profile_fields- .map((f) => user_profile.get_custom_profile_field_data(user, f, field_types))+ .flatMap((f) => user_profile.get_custom_profile_field_data(user, f, field_types) ?? []).filter((f) => f.display_in_profile_summary && f.value !== undefined && f.value !== null);const user_id_string = user.user_id.toString();diff --git a/web/src/user_profile.js b/web/src/user_profile.jsindex 7ddee947a19..017aa9787ba 100644--- a/web/src/user_profile.js+++ b/web/src/user_profile.js@@ -315,10 +315,10 @@ export function get_custom_profile_field_data(user, field, field_types) {const profile_field = {};if (!field_value) {- return profile_field;+ return undefined;}if (!field_value.value) {- return profile_field;+ return undefined;}profile_field.id = field.id;profile_field.name = field.name;@@ -378,7 +378,7 @@ export function update_user_custom_profile_fields(user) {const field_types = realm.custom_profile_field_types;const profile_fields = realm.custom_profile_fields- .map((f) => get_custom_profile_field_data(user, f, field_types))+ .flatMap((f) => get_custom_profile_field_data(user, f, field_types) ?? []).filter((f) => f.name !== undefined);const profile_data = {profile_fields};@@ -440,7 +440,7 @@ export function show_user_profile_access_error_modal() {export function show_user_profile(user, default_tab_key = "profile-tab") {const field_types = realm.custom_profile_field_types;const profile_data = realm.custom_profile_fields- .map((f) => get_custom_profile_field_data(user, f, field_types))+ .flatMap((f) => get_custom_profile_field_data(user, f, field_types) ?? []).filter((f) => f.name !== undefined);const user_streams = stream_data.get_streams_for_user(user.user_id).subscribed;// We only show the subscribe widget if the user is an admin, the user has opened their own profile,