stream_settings_api: Adjust set_stream_property usage.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-11-01 22:18:01 -07:00 committed by Tim Abbott
parent bb15b2d708
commit 1c5321e57f
5 changed files with 20 additions and 11 deletions

View File

@ -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"),
);
});

View File

@ -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) {

View File

@ -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();
});

View File

@ -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});
}

View File

@ -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) {