stream_data: Remove page_params.notifications_stream.

We shouldn't add redundant data to page_params. Since we already have
page_params.realm_notifications_stream_id, we can use that value instead
of creating page_params.notifications_stream.

We, however, still need the name of the notifications stream to render
it in templates. Thus we create stream_data.get_notifications_stream().
This commit is contained in:
Rohitt Vashishtha
2020-04-14 16:25:18 +05:30
committed by Tim Abbott
parent fe5a1eeaeb
commit e79935dbf7
4 changed files with 42 additions and 42 deletions

View File

@@ -101,7 +101,7 @@ const stream_name_error = (function () {
function update_announce_stream_state() {
// If there is no notifications_stream, we simply hide the widget.
if (!page_params.notifications_stream) {
if (page_params.realm_notifications_stream_id === -1) {
$('#announce-new-stream').hide();
return;
}
@@ -174,7 +174,7 @@ function create_stream() {
}
data.stream_post_policy = JSON.stringify(stream_post_policy);
const announce = !!page_params.notifications_stream &&
const announce = page_params.realm_notifications_stream_id !== -1 &&
$('#announce-new-stream input').prop('checked');
data.announce = JSON.stringify(announce);
@@ -274,7 +274,7 @@ exports.show_new_stream_modal = function () {
// public, "announce stream" on.
$('#make-invite-only input:radio[value=public]').prop('checked', true);
if (page_params.notifications_stream) {
if (page_params.realm_notifications_stream_id !== -1) {
$('#announce-new-stream').show();
$('#announce-new-stream input').prop('disabled', false);
$('#announce-new-stream input').prop('checked', true);
@@ -437,7 +437,8 @@ exports.set_up_handlers = function () {
announce_stream_docs.popover({
placement: "right",
content: render_announce_stream_docs({
notifications_stream: page_params.notifications_stream}),
notifications_stream: stream_data.get_notifications_stream(),
}),
html: true,
trigger: "manual"});
announce_stream_docs.popover('show');