settings: Fix live-update bug for privacy settings.

The following three privacy settings weren't being live
updated across multiple browser tabs/windows:
* send_stream_typing_notifications
* send_private_typing_notifications
* send_read_receipts

This commit fixes the bug.
This commit is contained in:
Prakhar Pratyush 2024-09-09 18:50:16 +05:30 committed by Tim Abbott
parent 340140954b
commit 75f6ae6d20
2 changed files with 23 additions and 3 deletions

View File

@ -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",
];

View File

@ -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();