mirror of https://github.com/zulip/zulip.git
static/js/stream_data: Deduplicate notification setting updates.
Commit also add `stream_data.js` to full test covered enforced files for `test-js-with-node` tests.
This commit is contained in:
parent
e0a78af494
commit
5c88475378
|
@ -300,6 +300,13 @@ exports.receives_notifications = function (stream_name, notification_name) {
|
|||
return page_params["enable_stream_" + notification_name];
|
||||
};
|
||||
|
||||
var stream_notification_settings = [
|
||||
"desktop_notifications",
|
||||
"audible_notifications",
|
||||
"push_notifications",
|
||||
"email_notifications",
|
||||
];
|
||||
|
||||
exports.update_calculated_fields = function (sub) {
|
||||
sub.is_admin = page_params.is_admin;
|
||||
// Admin can change any stream's name & description either stream is public or
|
||||
|
@ -326,26 +333,9 @@ exports.update_calculated_fields = function (sub) {
|
|||
exports.update_subscribers_count(sub);
|
||||
|
||||
// Apply the defaults for our notification settings for rendering.
|
||||
if (sub.email_notifications === null) {
|
||||
sub.email_notifications_display = page_params.enable_stream_email_notifications;
|
||||
} else {
|
||||
sub.email_notifications_display = sub.email_notifications;
|
||||
}
|
||||
if (sub.push_notifications === null) {
|
||||
sub.push_notifications_display = page_params.enable_stream_push_notifications;
|
||||
} else {
|
||||
sub.push_notifications_display = sub.push_notifications;
|
||||
}
|
||||
if (sub.desktop_notifications === null) {
|
||||
sub.desktop_notifications_display = page_params.enable_stream_desktop_notifications;
|
||||
} else {
|
||||
sub.desktop_notifications_display = sub.desktop_notifications;
|
||||
}
|
||||
if (sub.audible_notifications === null) {
|
||||
sub.audible_notifications_display = page_params.enable_stream_audible_notifications;
|
||||
} else {
|
||||
sub.audible_notifications_display = sub.audible_notifications;
|
||||
}
|
||||
_.each(stream_notification_settings, function (setting) {
|
||||
sub[setting + "_display"] = exports.receives_notifications(sub.name, setting);
|
||||
});
|
||||
};
|
||||
|
||||
exports.all_subscribed_streams_are_in_home_view = function () {
|
||||
|
|
|
@ -70,9 +70,7 @@ enforce_fully_covered = {
|
|||
# 'static/js/settings_ui.js',
|
||||
'static/js/settings_muting.js',
|
||||
'static/js/settings_user_groups.js',
|
||||
# Removed because of an intermediate state of the subscription
|
||||
# notifications migration.
|
||||
# 'static/js/stream_data.js',
|
||||
'static/js/stream_data.js',
|
||||
'static/js/stream_events.js',
|
||||
'static/js/stream_sort.js',
|
||||
'static/js/top_left_corner.js',
|
||||
|
|
Loading…
Reference in New Issue