settings: Refactor change_notification_setting to have url parameter.

We refactor the change_notification_setting function to have a url
parameter instead of directly using "/json/settings" directly.

This change will help us in using the same code for realm-level
settings also.
This commit is contained in:
Sahil Batra 2021-08-26 15:04:40 +05:30 committed by Tim Abbott
parent 44c820da3a
commit ebab2a89fb
1 changed files with 4 additions and 2 deletions

View File

@ -44,10 +44,10 @@ function rerender_ui() {
} }
} }
function change_notification_setting(setting, value, status_element) { function change_notification_setting(setting, value, status_element, url) {
const data = {}; const data = {};
data[setting] = value; data[setting] = value;
settings_ui.do_settings_change(channel.patch, "/json/settings", data, status_element); settings_ui.do_settings_change(channel.patch, url, data, status_element);
} }
function update_desktop_icon_count_display() { function update_desktop_icon_count_display() {
@ -78,6 +78,7 @@ export function set_enable_marketing_emails_visibility() {
export function set_up() { export function set_up() {
const container = $("#user-notification-settings"); const container = $("#user-notification-settings");
const patch_url = "/json/settings";
container.on("change", "input, select", function (e) { container.on("change", "input, select", function (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -91,6 +92,7 @@ export function set_up() {
setting_name, setting_name,
settings_org.get_input_element_value(this), settings_org.get_input_element_value(this),
input_elem.closest(".subsection-parent").find(".alert-notification"), input_elem.closest(".subsection-parent").find(".alert-notification"),
patch_url,
); );
}); });