mirror of https://github.com/zulip/zulip.git
custom fields: Fix exception in rendering custom profile field template.
The function `settings_account.add_custom_profile_fields_to_settings` called twice, which resulted in two templates objects being rendered. The function also didn't check whether settings overlay was open or not when processing new events, and thus would throw an "undefined" error if a custom profile field was editing while the overlay was not open. Fixes #9668.
This commit is contained in:
parent
51ae82fbcf
commit
40590bb6b9
|
@ -35,6 +35,7 @@ set_global('settings_emoji', {
|
|||
set_global('settings_account', {
|
||||
update_email_change_display: noop,
|
||||
update_name_change_display: noop,
|
||||
add_custom_profile_fields_to_settings: noop,
|
||||
});
|
||||
set_global('settings_display', {
|
||||
update_page: noop,
|
||||
|
|
|
@ -175,6 +175,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
|||
case 'custom_profile_fields':
|
||||
page_params.custom_profile_fields = event.fields;
|
||||
settings_profile_fields.populate_profile_fields(page_params.custom_profile_fields);
|
||||
settings_account.add_custom_profile_fields_to_settings();
|
||||
break;
|
||||
|
||||
case 'realm_domains':
|
||||
|
|
|
@ -64,6 +64,11 @@ function update_user_custom_profile_fields(fields, method) {
|
|||
}
|
||||
|
||||
exports.add_custom_profile_fields_to_settings = function () {
|
||||
if (!overlays.settings_open()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#account-settings .custom-profile-fields-form").html("");
|
||||
var all_custom_fields = page_params.custom_profile_fields;
|
||||
|
||||
all_custom_fields.forEach(function (field) {
|
||||
|
|
|
@ -167,9 +167,6 @@ exports.reset = function () {
|
|||
};
|
||||
|
||||
exports.populate_profile_fields = function (profile_fields_data) {
|
||||
$("#account-settings .custom-profile-fields-form").html("");
|
||||
settings_account.add_custom_profile_fields_to_settings();
|
||||
|
||||
if (!meta.loaded) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue