mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
settings: Move the user-privacy settings related code at one place.
This commit makes small refactoring to place all the user-privacy settings code in 'server_events_dispatch.js' at one place and use a common function 'settings_account.update_privacy_settings_box' to update the UI. This also helps in early return instead of executing a lot of `if` statements related to user-preferences settings.
This commit is contained in:
committed by
Tim Abbott
parent
75f6ae6d20
commit
00fb8f3014
@@ -710,11 +710,16 @@ export function dispatch_normal_event(event) {
|
|||||||
"send_stream_typing_notifications",
|
"send_stream_typing_notifications",
|
||||||
"send_private_typing_notifications",
|
"send_private_typing_notifications",
|
||||||
"send_read_receipts",
|
"send_read_receipts",
|
||||||
|
"presence_enabled",
|
||||||
|
"email_address_visibility",
|
||||||
];
|
];
|
||||||
|
|
||||||
if (privacy_settings.includes(event.property)) {
|
if (privacy_settings.includes(event.property)) {
|
||||||
user_settings[event.property] = event.value;
|
user_settings[event.property] = event.value;
|
||||||
settings_account.update_privacy_settings_box(event.property);
|
settings_account.update_privacy_settings_box(event.property);
|
||||||
|
if (event.property === "presence_enabled") {
|
||||||
|
activity_ui.redraw_user(current_user.user_id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,17 +866,6 @@ export function dispatch_normal_event(event) {
|
|||||||
if (event.property === "web_escape_navigates_to_home_view") {
|
if (event.property === "web_escape_navigates_to_home_view") {
|
||||||
$("#go-to-home-view-hotkey-help").toggleClass("notdisplayed", !event.value);
|
$("#go-to-home-view-hotkey-help").toggleClass("notdisplayed", !event.value);
|
||||||
}
|
}
|
||||||
if (event.property === "presence_enabled") {
|
|
||||||
user_settings.presence_enabled = event.value;
|
|
||||||
$("#user_presence_enabled").prop("checked", user_settings.presence_enabled);
|
|
||||||
activity_ui.redraw_user(current_user.user_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (event.property === "email_address_visibility") {
|
|
||||||
user_settings.email_address_visibility = event.value;
|
|
||||||
$("#user_email_address_visibility").val(event.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
settings_preferences.update_page(event.property);
|
settings_preferences.update_page(event.property);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1117,6 +1117,7 @@ run_test("user_settings", ({override}) => {
|
|||||||
event = event_fixtures.user_settings__presence_disabled;
|
event = event_fixtures.user_settings__presence_disabled;
|
||||||
user_settings.presence_enabled = true;
|
user_settings.presence_enabled = true;
|
||||||
override(activity_ui, "redraw_user", noop);
|
override(activity_ui, "redraw_user", noop);
|
||||||
|
override(settings_account, "update_privacy_settings_box", noop);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(user_settings.presence_enabled, false);
|
assert_same(user_settings.presence_enabled, false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user