settings: Fix streams incorrectly appearing in notification settings.

There is a bug when a newly created stream appears in the notification
settings table if user changes any setting in 'Streams' row of the
table even though user has not changed the notification setting of
the stream and thus the stream should follow the global-level values.

The stream is correctly not added to the table if user changes the
setting after reloading once after creating the stream.

The bug is due to the notification settings of the new-stream being
set to the user's global settings at time of stream creation which
are not overridden since the stream-creation event contains only
stream fields and not subscription fields. And the newly created
stream is not present in the table after reload because during
initialization of the client-level data structures the notification
setting values are overridden by the values stored in server.

This commit fixes create_sub_from_server_data code to initially have
the notification settings set as null in the sub object which are
overridden by the correct value during initialization. This keeps
the notification setting values as null just after stream creation.

Fixes #19933.
This commit is contained in:
Sahil Batra
2021-10-08 17:21:55 +05:30
committed by Tim Abbott
parent ed5d345aed
commit 6aa5b3be51

View File

@@ -693,11 +693,11 @@ export function create_sub_from_server_data(attrs) {
newly_subscribed: false,
is_muted: false,
invite_only: false,
desktop_notifications: user_settings.enable_stream_desktop_notifications,
audible_notifications: user_settings.enable_stream_audible_notifications,
push_notifications: user_settings.enable_stream_push_notifications,
email_notifications: user_settings.enable_stream_email_notifications,
wildcard_mentions_notify: user_settings.wildcard_mentions_notify,
desktop_notifications: null,
audible_notifications: null,
push_notifications: null,
email_notifications: null,
wildcard_mentions_notify: null,
description: "",
rendered_description: "",
first_message_id: attrs.first_message_id,