From 1c5321e57f578ebd4a29e7224e60fa4567f92a7b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 1 Nov 2023 22:18:01 -0700 Subject: [PATCH] stream_settings_api: Adjust set_stream_property usage. Signed-off-by: Anders Kaseorg --- web/src/settings_notifications.js | 9 ++++++--- web/src/stream_edit.js | 9 ++++++--- web/src/stream_popover.js | 5 ++++- web/src/stream_settings_api.js | 6 +++--- web/src/stream_settings_ui.js | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/web/src/settings_notifications.js b/web/src/settings_notifications.js index 0d8a9c3eed..a620578b24 100644 --- a/web/src/settings_notifications.js +++ b/web/src/settings_notifications.js @@ -139,7 +139,11 @@ function stream_notification_setting_changed(e) { sub[setting] = user_settings[settings_config.generalize_stream_notification_setting[setting]]; } - stream_settings_api.set_stream_property(sub, setting, e.target.checked, $status_element); + stream_settings_api.set_stream_property( + sub, + {property: setting, value: e.target.checked}, + $status_element, + ); } export function set_up(settings_panel) { @@ -368,8 +372,7 @@ export function initialize() { stream_settings_api.set_stream_property( sub, - "is_muted", - !sub.is_muted, + {property: "is_muted", value: !sub.is_muted}, $row.closest(".subsection-parent").find(".alert-notification"), ); }); diff --git a/web/src/stream_edit.js b/web/src/stream_edit.js index 78456edf7b..54db36b255 100644 --- a/web/src/stream_edit.js +++ b/web/src/stream_edit.js @@ -300,8 +300,7 @@ function stream_is_muted_changed(e) { stream_settings_api.set_stream_property( sub, - "is_muted", - e.target.checked, + {property: "is_muted", value: e.target.checked}, $(`#stream_change_property_status${CSS.escape(sub.stream_id)}`), ); } @@ -322,7 +321,11 @@ function stream_setting_changed(e) { sub[setting] = user_settings[settings_config.generalize_stream_notification_setting[setting]]; } - stream_settings_api.set_stream_property(sub, setting, e.target.checked, $status_element); + stream_settings_api.set_stream_property( + sub, + {property: setting, value: e.target.checked}, + $status_element, + ); } export function archive_stream(stream_id, $alert_element, $stream_row) { diff --git a/web/src/stream_popover.js b/web/src/stream_popover.js index 9cb70715e4..2402788d55 100644 --- a/web/src/stream_popover.js +++ b/web/src/stream_popover.js @@ -154,7 +154,10 @@ function build_stream_popover(opts) { $popper.on("click", ".toggle_stream_muted", (e) => { const sub = stream_popover_sub(e); hide_stream_popover(); - stream_settings_api.set_stream_property(sub, "is_muted", !sub.is_muted); + stream_settings_api.set_stream_property(sub, { + property: "is_muted", + value: !sub.is_muted, + }); e.stopPropagation(); }); diff --git a/web/src/stream_settings_api.js b/web/src/stream_settings_api.js index 21535e62ec..c070f36fe6 100644 --- a/web/src/stream_settings_api.js +++ b/web/src/stream_settings_api.js @@ -17,12 +17,12 @@ export function bulk_set_stream_property(sub_data, $status_element) { return undefined; } -export function set_stream_property(sub, property, value, $status_element) { - const sub_data = {stream_id: sub.stream_id, property, value}; +export function set_stream_property(sub, data, $status_element) { + const sub_data = {stream_id: sub.stream_id, ...data}; bulk_set_stream_property([sub_data], $status_element); } export function set_color(stream_id, color) { const sub = sub_store.get(stream_id); - set_stream_property(sub, "color", color); + set_stream_property(sub, {property: "color", value: color}); } diff --git a/web/src/stream_settings_ui.js b/web/src/stream_settings_ui.js index 9820c39c7d..6d8c8c7d5a 100644 --- a/web/src/stream_settings_ui.js +++ b/web/src/stream_settings_ui.js @@ -92,7 +92,7 @@ function should_list_all_streams() { } export function toggle_pin_to_top_stream(sub) { - stream_settings_api.set_stream_property(sub, "pin_to_top", !sub.pin_to_top); + stream_settings_api.set_stream_property(sub, {property: "pin_to_top", value: !sub.pin_to_top}); } export function update_stream_name(sub, new_name) {