From 7448e2bd42afbef6020d7c2f408b1679d0416c77 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Sun, 27 Nov 2022 23:08:48 +0530 Subject: [PATCH] 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. --- static/js/settings_org.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/static/js/settings_org.js b/static/js/settings_org.js index dedf230d98..8efedaedf6 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -24,8 +24,6 @@ import * as settings_ui from "./settings_ui"; import * as stream_settings_data from "./stream_settings_data"; import * as ui_report from "./ui_report"; -export let parse_time_limit; - const meta = { loaded: false, }; @@ -766,6 +764,10 @@ function get_auth_method_list_data() { 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) { 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"); }); - 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) { let data = {};