settings: Fix custom input for user email-notification-batching setting.

The custom input was not being shown when changing user email
notification batching period setting dropdown to "Custom" option.
This was because parse_time_limit was undefined in case organization
settings was not loaded till then, and the code raised an error.

This commit changes the code to define parse_limit_function at
module-level instead of defining it in
register_save_discard_widget_handlers which is called only when
build_page is called which happens only when organization settings
is opened before changing the notification batching setting.

Fixes #23674.
This commit is contained in:
Sahil Batra 2022-11-27 23:08:48 +05:30 committed by Tim Abbott
parent 5cc92365b8
commit 7448e2bd42
1 changed files with 4 additions and 6 deletions

View File

@ -24,8 +24,6 @@ import * as settings_ui from "./settings_ui";
import * as stream_settings_data from "./stream_settings_data"; import * as stream_settings_data from "./stream_settings_data";
import * as ui_report from "./ui_report"; import * as ui_report from "./ui_report";
export let parse_time_limit;
const meta = { const meta = {
loaded: false, loaded: false,
}; };
@ -766,6 +764,10 @@ function get_auth_method_list_data() {
return new_auth_methods; return new_auth_methods;
} }
export function parse_time_limit($elem) {
return Math.floor(Number.parseFloat(Number($elem.val()), 10).toFixed(1) * 60);
}
function get_time_limit_setting_value($input_elem, for_api_data = true) { function get_time_limit_setting_value($input_elem, for_api_data = true) {
const select_elem_val = $input_elem.val(); const select_elem_val = $input_elem.val();
@ -969,10 +971,6 @@ export function register_save_discard_widget_handlers(
change_save_button_state($save_btn_controls, "discarded"); change_save_button_state($save_btn_controls, "discarded");
}); });
parse_time_limit = function parse_time_limit($elem) {
return Math.floor(Number.parseFloat(Number($elem.val()), 10).toFixed(1) * 60);
};
function get_complete_data_for_subsection(subsection) { function get_complete_data_for_subsection(subsection) {
let data = {}; let data = {};