mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
settings: Move 'enter_sends' setting to property_types dict.
This commit moves "enter_sends" setting to property_types dict. With this change, changing enter_sends setting also sends an event of type "update_display_settings" and thus enables us to live-update the UI.
This commit is contained in:
@@ -24,6 +24,7 @@ const activity = mock_esm("../../static/js/activity");
|
||||
const alert_words_ui = mock_esm("../../static/js/alert_words_ui");
|
||||
const attachments_ui = mock_esm("../../static/js/attachments_ui");
|
||||
const bot_data = mock_esm("../../static/js/bot_data");
|
||||
const compose = mock_esm("../../static/js/compose");
|
||||
const composebox_typeahead = mock_esm("../../static/js/composebox_typeahead");
|
||||
const emoji_picker = mock_esm("../../static/js/emoji_picker");
|
||||
const hotspots = mock_esm("../../static/js/hotspots");
|
||||
@@ -64,7 +65,6 @@ const ui = mock_esm("../../static/js/ui");
|
||||
const unread_ops = mock_esm("../../static/js/unread_ops");
|
||||
const user_events = mock_esm("../../static/js/user_events");
|
||||
const user_groups = mock_esm("../../static/js/user_groups");
|
||||
mock_esm("../../static/js/compose");
|
||||
mock_esm("../../static/js/giphy");
|
||||
|
||||
const electron_bridge = set_global("electron_bridge", {});
|
||||
@@ -788,6 +788,13 @@ run_test("update_display_settings", ({override}) => {
|
||||
assert.equal(stub.num_calls, 1);
|
||||
assert_same(page_params.demote_inactive_streams, 2);
|
||||
}
|
||||
|
||||
override(compose, "toggle_enter_sends_ui", noop);
|
||||
|
||||
event = event_fixtures.update_display_settings__enter_sends;
|
||||
page_params.enter_sends = false;
|
||||
dispatch(event);
|
||||
assert_same(page_params.enter_sends, true);
|
||||
});
|
||||
|
||||
run_test("update_global_notifications", ({override}) => {
|
||||
|
||||
@@ -691,6 +691,13 @@ exports.fixtures = {
|
||||
user: test_user.email,
|
||||
},
|
||||
|
||||
update_display_settings__enter_sends: {
|
||||
type: "update_display_settings",
|
||||
setting_name: "enter_sends",
|
||||
setting: true,
|
||||
user: test_user.email,
|
||||
},
|
||||
|
||||
update_display_settings__fluid_layout_width: {
|
||||
type: "update_display_settings",
|
||||
setting_name: "fluid_layout_width",
|
||||
|
||||
@@ -627,6 +627,12 @@ export function dispatch_normal_event(event) {
|
||||
message_list.narrowed.rerender();
|
||||
}
|
||||
}
|
||||
if (event.setting_name === "enter_sends") {
|
||||
page_params.enter_sends = event.setting;
|
||||
$("#enter_sends").prop("checked", page_params.enter_sends);
|
||||
compose.toggle_enter_sends_ui();
|
||||
break;
|
||||
}
|
||||
settings_display.update_page();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5039,11 +5039,6 @@ def do_change_notification_settings(
|
||||
send_event(user_profile.realm, event, [user_profile.id])
|
||||
|
||||
|
||||
def do_change_enter_sends(user_profile: UserProfile, enter_sends: bool) -> None:
|
||||
user_profile.enter_sends = enter_sends
|
||||
user_profile.save(update_fields=["enter_sends"])
|
||||
|
||||
|
||||
def do_set_user_display_setting(
|
||||
user_profile: UserProfile, setting_name: str, setting_value: Union[bool, str, int]
|
||||
) -> None:
|
||||
|
||||
@@ -502,6 +502,10 @@ def fetch_initial_state_data(
|
||||
|
||||
if want("update_display_settings"):
|
||||
for prop in UserProfile.property_types:
|
||||
if prop == "enter_sends":
|
||||
# This will be removed when we make the API change to
|
||||
# move this to the update_display_settings event type.
|
||||
continue
|
||||
state[prop] = getattr(settings_user, prop)
|
||||
state["emojiset_choices"] = UserProfile.emojiset_choices()
|
||||
state["timezone"] = settings_user.timezone
|
||||
|
||||
@@ -1351,6 +1351,7 @@ class UserBaseSettings(models.Model):
|
||||
demote_inactive_streams=int,
|
||||
dense_mode=bool,
|
||||
emojiset=str,
|
||||
enter_sends=bool,
|
||||
fluid_layout_width=bool,
|
||||
high_contrast_mode=bool,
|
||||
left_side_userlist=bool,
|
||||
|
||||
@@ -198,9 +198,6 @@ class ChangeSettingsTest(ZulipTestCase):
|
||||
for display_setting in boolean_settings:
|
||||
self.check_for_toggle_param_patch("/json/settings", display_setting)
|
||||
|
||||
def test_enter_sends_setting(self) -> None:
|
||||
self.check_for_toggle_param_patch("/json/settings", "enter_sends")
|
||||
|
||||
def test_wrong_old_password(self) -> None:
|
||||
self.login("hamlet")
|
||||
result = self.client_patch(
|
||||
|
||||
@@ -21,7 +21,6 @@ from zerver.decorator import human_users_only
|
||||
from zerver.lib.actions import (
|
||||
check_change_full_name,
|
||||
do_change_avatar_fields,
|
||||
do_change_enter_sends,
|
||||
do_change_notification_settings,
|
||||
do_change_password,
|
||||
do_change_user_delivery_email,
|
||||
@@ -275,9 +274,6 @@ def json_change_settings(
|
||||
if timezone is not None and user_profile.timezone != timezone:
|
||||
do_set_user_display_setting(user_profile, "timezone", timezone)
|
||||
|
||||
if enter_sends is not None and user_profile.enter_sends != enter_sends:
|
||||
do_change_enter_sends(user_profile, enter_sends)
|
||||
|
||||
# TODO: Do this more generally.
|
||||
from zerver.lib.request import get_request_notes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user