stream_edit: Live update UI when a stream becomes web public.

This commit is contained in:
Aman Agrawal 2020-11-10 20:27:14 +05:30 committed by Tim Abbott
parent faf43b7a3e
commit 8c50a08066
6 changed files with 20 additions and 1 deletions

View File

@ -205,6 +205,7 @@ test("update_property", ({override}) => {
override(stream_settings_ui, "update_stream_privacy", stub.f);
stream_events.update_property(stream_id, "invite_only", true, {
history_public_to_subscribers: true,
is_web_public: false,
});
assert.equal(stub.num_calls, 1);
const args = stub.get_args("sub", "val");
@ -212,6 +213,7 @@ test("update_property", ({override}) => {
assert.deepEqual(args.val, {
invite_only: true,
history_public_to_subscribers: true,
is_web_public: false,
});
}

View File

@ -448,6 +448,7 @@ export function dispatch_normal_event(event) {
stream_events.update_property(event.stream_id, event.property, event.value, {
rendered_description: event.rendered_description,
history_public_to_subscribers: event.history_public_to_subscribers,
is_web_public: event.is_web_public,
});
settings_streams.update_default_streams_table();
break;

View File

@ -454,6 +454,7 @@ export function update_stream_post_policy(sub, stream_post_policy) {
export function update_stream_privacy(sub, values) {
sub.invite_only = values.invite_only;
sub.history_public_to_subscribers = values.history_public_to_subscribers;
sub.is_web_public = values.is_web_public;
}
export function update_message_retention_setting(sub, message_retention_days) {

View File

@ -664,32 +664,45 @@ function change_stream_privacy(e) {
let invite_only;
let history_public_to_subscribers;
let is_web_public;
switch (privacy_setting) {
case stream_data.stream_privacy_policy_values.public.code: {
invite_only = false;
history_public_to_subscribers = true;
is_web_public = false;
break;
}
case stream_data.stream_privacy_policy_values.private.code: {
invite_only = true;
history_public_to_subscribers = false;
is_web_public = false;
break;
}
case stream_data.stream_privacy_policy_values.web_public.code: {
invite_only = false;
history_public_to_subscribers = true;
is_web_public = true;
break;
}
default: {
invite_only = true;
history_public_to_subscribers = true;
is_web_public = false;
}
}
if (
sub.invite_only !== invite_only ||
sub.history_public_to_subscribers !== history_public_to_subscribers
sub.history_public_to_subscribers !== history_public_to_subscribers ||
sub.is_web_public !== is_web_public
) {
data.is_private = JSON.stringify(invite_only);
data.history_public_to_subscribers = JSON.stringify(history_public_to_subscribers);
data.is_web_public = JSON.stringify(is_web_public);
}
let message_retention_days = $(

View File

@ -82,6 +82,7 @@ export function update_property(stream_id, property, value, other_values) {
stream_settings_ui.update_stream_privacy(sub, {
invite_only: value,
history_public_to_subscribers: other_values.history_public_to_subscribers,
is_web_public: other_values.is_web_public,
});
break;
case "stream_post_policy":

View File

@ -311,6 +311,7 @@ export function redraw_stream_privacy(sub) {
const args = {
invite_only: sub.invite_only,
is_web_public: sub.is_web_public,
dark_background,
};