Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

refactor: Remove foo_display fields on subs.

Steve Howell36632637dcdf
diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js
index 0ac5edea27a..e979d253779 100644
--- a/frontend_tests/node_tests/stream_data.js
+++ b/frontend_tests/node_tests/stream_data.js
@@ -570,6 +570,9 @@ test("notifications", () => {
];
assert.deepEqual(unmatched_streams, expected_streams);
+
+ // Get line coverage on defensive code with bogus stream_id.
+ assert(!stream_data.receives_notifications(999999));
});
const tony = {
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index 4f72ff44e48..5f7e3b1227c 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -421,7 +421,13 @@ export function stream_settings(sub) {
is_notification_setting: is_notification_setting(setting),
};
if (is_notification_setting(setting)) {
- ret.is_checked = sub[setting + "_display"] && !check_realm_setting[setting];
+ // This block ensures we correctly display to users the
+ // current state of stream-level notification settings
+ // with a value of `null`, which inherit the user's global
+ // notification settings for streams.
+ ret.is_checked =
+ stream_data.receives_notifications(sub.stream_id, setting) &&
+ !check_realm_setting[setting];
ret.is_disabled = ret.is_disabled || sub.is_muted;
return ret;
}
diff --git a/static/js/stream_settings_data.js b/static/js/stream_settings_data.js
index c7811f63ad3..da8c649afa1 100644
--- a/static/js/stream_settings_data.js
+++ b/static/js/stream_settings_data.js
@@ -59,11 +59,6 @@ export function update_calculated_fields(sub) {
sub.preview_url = hash_util.by_stream_uri(sub.stream_id);
sub.is_old_stream = sub.stream_weekly_traffic !== null;
-
- // Apply the defaults for our notification settings for rendering.
- for (const setting of settings_config.stream_specific_notification_settings) {
- sub[setting + "_display"] = stream_data.receives_notifications(sub.stream_id, setting);
- }
}
export function get_unmatched_streams_for_notification_settings() {