Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Fix live-update bug for privacy settings.

Prakhar Pratyush75f6ae6d205d
diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js
index f266f9237a4..81b45694dc7 100644
--- a/web/src/server_events_dispatch.js
+++ b/web/src/server_events_dispatch.js
@@ -706,6 +706,18 @@ export function dispatch_normal_event(event) {
break;
}
+ const privacy_settings = [
+ "send_stream_typing_notifications",
+ "send_private_typing_notifications",
+ "send_read_receipts",
+ ];
+
+ if (privacy_settings.includes(event.property)) {
+ user_settings[event.property] = event.value;
+ settings_account.update_privacy_settings_box(event.property);
+ break;
+ }
+
const user_preferences = [
"color_scheme",
"web_font_size_px",
@@ -729,9 +741,6 @@ export function dispatch_normal_event(event) {
"web_animate_image_previews",
"web_stream_unreads_count_display_policy",
"starred_message_counts",
- "send_stream_typing_notifications",
- "send_private_typing_notifications",
- "send_read_receipts",
"web_navigate_to_sent_message",
"enter_sends",
];
diff --git a/web/src/settings_account.js b/web/src/settings_account.js
index d5272c52a10..f600f241a0f 100644
--- a/web/src/settings_account.js
+++ b/web/src/settings_account.js
@@ -20,6 +20,7 @@ import * as overlays from "./overlays";
import {page_params} from "./page_params";
import * as people from "./people";
import * as settings_bots from "./settings_bots";
+import * as settings_components from "./settings_components";
import * as settings_data from "./settings_data";
import * as settings_org from "./settings_org";
import * as settings_ui from "./settings_ui";
@@ -250,6 +251,16 @@ export function hide_confirm_email_banner() {
$("#account-settings-status").hide();
}
+export function update_privacy_settings_box(property) {
+ if (!overlays.settings_open()) {
+ return;
+ }
+
+ const $container = $("#account-settings");
+ const $input_elem = $container.find(`[name=${CSS.escape(property)}]`);
+ settings_components.set_input_element_value($input_elem, user_settings[property]);
+}
+
export function set_up() {
// Add custom profile fields elements to user account settings.
add_custom_profile_fields_to_settings();