stream_edit: Fix realm time sync of notifications setting checkbox.

This fixes the buggy behavior for streams which inherits the notification
setting from UserProfile, and are actively opened in "Streams > Stream
settings", if a user has opened two browser windows, and changes the
notification setting from "Settings > Notifications", then the changes
don't reflect such "Streams > Stream settings" notification setting
checkboxes for such stream.

Partially fixes: #12304.
This commit is contained in:
Pragati Agrawal 2020-02-04 17:45:09 +05:30 committed by Tim Abbott
parent e79c28e13c
commit b975d693bd
2 changed files with 16 additions and 0 deletions

View File

@ -756,6 +756,12 @@ exports.handle_global_notification_updates = function (notification_name, settin
page_params[notification_name] = setting;
}
if (settings_notifications.all_notifications.settings.stream_notification_settings.indexOf(
notification_name) !== -1) {
notification_name = notification_name.replace("enable_stream_", "");
stream_ui_updates.update_notification_setting_checkbox(notification_name);
}
if (notification_name === "notification_sound") {
// Change the sound source with the new page `notification_sound`.
update_notification_sound_source();

View File

@ -96,6 +96,16 @@ exports.update_change_stream_privacy_settings = function (sub) {
}
};
exports.update_notification_setting_checkbox = function (notification_name) {
const stream_row = $('#subscriptions_table .stream-row.active');
if (!stream_row.length) {
return;
}
const stream_id = stream_row.data('stream-id');
$(`#${notification_name}_${stream_id}`).prop("checked", stream_data.receives_notifications(
stream_data.maybe_get_stream_name(stream_id), notification_name));
};
exports.update_stream_row_in_settings_tab = function (sub) {
// This function display/hide stream row in stream settings tab,
// used to display immediate effect of add/removal subscription event.