stream_settings: Add stream "reset to default notifications" button.

This commit introduces a "reset to default notifications" button to
the personal panel in stream settings. On clicking, it unmutes the
current stream and resets all its notification configurations to
default user settings.

Fixes zulip#27624.
This commit is contained in:
Pratik Chanda
2024-01-20 03:51:04 +05:30
committed by Tim Abbott
parent 3975c508b5
commit f4260cf40d
2 changed files with 28 additions and 0 deletions

View File

@@ -289,6 +289,25 @@ export function update_muting_rendering(sub) {
$edit_container.find(".mute-note").toggleClass("hide-mute-note", !sub.is_muted);
}
function stream_notification_reset(e) {
const sub = get_sub_for_target(e.target);
const data = [{stream_id: sub.stream_id, property: "is_muted", value: false}];
for (const [per_stream_setting_name, global_setting_name] of Object.entries(
settings_config.generalize_stream_notification_setting,
)) {
data.push({
stream_id: sub.stream_id,
property: per_stream_setting_name,
value: user_settings[global_setting_name],
});
}
stream_settings_api.bulk_set_stream_property(
data,
$(`#stream_change_property_status${CSS.escape(sub.stream_id)}`),
);
}
function stream_is_muted_changed(e) {
const sub = get_sub_for_target(e.target);
if (!sub) {
@@ -537,6 +556,12 @@ export function initialize() {
});
});
$("#streams_overlay_container").on(
"click",
".subsection-parent .reset-stream-notifications-button",
stream_notification_reset,
);
$("#streams_overlay_container").on(
"change",
"#sub_is_muted_setting .sub_setting_control",