stream_settings: Add code to live-update stream settings.

Fixes part of #19519.
This commit is contained in:
Sahil Batra 2022-11-11 22:14:25 +05:30 committed by Tim Abbott
parent 6237a7b284
commit 404ce8887c
2 changed files with 20 additions and 0 deletions

View File

@ -213,6 +213,8 @@ export function update_stream_privacy(slim_sub, values) {
// Update UI elements
update_left_panel_row(sub);
stream_ui_updates.update_setting_element(sub, "stream_privacy");
stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);
stream_ui_updates.update_stream_privacy_icon_in_settings(sub);
stream_ui_updates.update_stream_subscription_type_text(sub);
stream_ui_updates.update_change_stream_privacy_settings(sub);
@ -233,11 +235,13 @@ export function update_stream_privacy(slim_sub, values) {
export function update_stream_post_policy(sub, new_value) {
stream_data.update_stream_post_policy(sub, new_value);
stream_ui_updates.update_stream_subscription_type_text(sub);
stream_ui_updates.update_setting_element(sub, "stream_post_policy");
}
export function update_message_retention_setting(sub, new_value) {
stream_data.update_message_retention_setting(sub, new_value);
stream_ui_updates.update_stream_subscription_type_text(sub);
stream_ui_updates.update_setting_element(sub, "message_retention_days");
}
export function set_color(stream_id, color) {
@ -314,6 +318,7 @@ export function update_settings_for_subscribed(slim_sub) {
stream_ui_updates.update_stream_row_in_settings_tab(sub);
stream_ui_updates.update_settings_button_for_sub(sub);
stream_ui_updates.update_change_stream_privacy_settings(sub);
stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);
} else {
add_sub_to_table(sub);
}
@ -342,6 +347,7 @@ export function update_settings_for_unsubscribed(slim_sub) {
stream_ui_updates.update_settings_button_for_sub(sub);
stream_ui_updates.update_regular_sub_settings(sub);
stream_ui_updates.update_change_stream_privacy_settings(sub);
stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);
// If user unsubscribed from private stream then user cannot subscribe to
// stream without invitation and cannot add subscribers to stream.

View File

@ -7,6 +7,7 @@ import render_stream_settings_tip from "../templates/stream_settings/stream_sett
import * as hash_util from "./hash_util";
import {$t} from "./i18n";
import {page_params} from "./page_params";
import * as settings_org from "./settings_org";
import * as stream_data from "./stream_data";
import * as stream_edit from "./stream_edit";
import * as stream_settings_containers from "./stream_settings_containers";
@ -137,6 +138,10 @@ export function update_change_stream_privacy_settings(sub) {
}
export function enable_or_disable_permission_settings_in_edit_panel(sub) {
if (!hash_util.is_editing_stream(sub.stream_id)) {
return;
}
const $stream_settings = stream_settings_containers.get_edit_container(sub);
const $general_settings_container = $stream_settings.find($("#stream_permission_settings"));
@ -268,3 +273,12 @@ export function update_add_subscriptions_elements(sub) {
);
}
}
export function update_setting_element(sub, setting_name) {
if (!hash_util.is_editing_stream(sub.stream_id)) {
return;
}
const $elem = $(`#id_${CSS.escape(setting_name)}`);
settings_org.discard_property_element_changes($elem, false, sub);
}