mirror of https://github.com/zulip/zulip.git
notifications: Warn if all PM notifications will be disabled.
This PR adds a modal to warn when user unchecks a box on the "PMs, mentions, and alerts" line of notifications panel that will result in all notifications for private messages and mentions being disabled. Fixes #24151.
This commit is contained in:
parent
ddb0a6bae9
commit
de8148bc9e
|
@ -1,9 +1,11 @@
|
|||
import $ from "jquery";
|
||||
|
||||
import render_confirm_disable_all_notifications from "../templates/confirm_dialog/confirm_disable_all_notifications.hbs";
|
||||
import render_stream_specific_notification_row from "../templates/settings/stream_specific_notification_row.hbs";
|
||||
|
||||
import * as channel from "./channel";
|
||||
import {$t} from "./i18n";
|
||||
import * as confirm_dialog from "./confirm_dialog";
|
||||
import {$t, $t_html} from "./i18n";
|
||||
import * as notifications from "./notifications";
|
||||
import {page_params} from "./page_params";
|
||||
import * as settings_config from "./settings_config";
|
||||
|
@ -196,6 +198,40 @@ export function set_up(settings_panel) {
|
|||
setting_name = "email_notifications_batching_period_seconds";
|
||||
}
|
||||
|
||||
if (
|
||||
settings_config.pm_mention_notification_settings.includes(setting_name) &&
|
||||
!setting_value
|
||||
) {
|
||||
let enabled_pm_mention_notifications_count = 0;
|
||||
const pm_mention_notification_settings =
|
||||
settings_config.get_notifications_table_row_data(
|
||||
settings_config.pm_mention_notification_settings,
|
||||
user_settings,
|
||||
);
|
||||
|
||||
for (const setting of pm_mention_notification_settings) {
|
||||
if (setting.is_checked && !setting.is_disabled) {
|
||||
enabled_pm_mention_notifications_count += 1;
|
||||
}
|
||||
}
|
||||
if (enabled_pm_mention_notifications_count === 1) {
|
||||
const html_body = render_confirm_disable_all_notifications();
|
||||
$input_elem.prop("checked", user_settings[setting_name]);
|
||||
|
||||
confirm_dialog.launch({
|
||||
html_heading: $t_html({defaultMessage: "Disable notifications?"}),
|
||||
html_body,
|
||||
on_click: () =>
|
||||
change_notification_setting(
|
||||
setting_name,
|
||||
setting_value,
|
||||
$input_elem.closest(".subsection-parent").find(".alert-notification"),
|
||||
),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
change_notification_setting(
|
||||
setting_name,
|
||||
setting_value,
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<p>
|
||||
{{#tr}}
|
||||
You are about to disable all notifications for private messages,
|
||||
@‑mentions and alerts, which may cause you to miss messages
|
||||
that require your timely attention.
|
||||
If you would like to temporarily disable all desktop notifications,
|
||||
consider <z-link>turning on "Do not disturb"</z-link> instead.
|
||||
{{#*inline "z-link"}}<a href="/help/do-not-disturb">{{> @partial-block}}</a>{{/inline}}
|
||||
{{/tr}}
|
||||
</p>
|
||||
|
||||
<p>{{t "Are you sure you want to continue?"}}</p>
|
Loading…
Reference in New Issue