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: Add 'web_navigate_to_sent_message' setting.

Prakhar Pratyush83414db72eec
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index a6776042b28..d5cd7fcbf7a 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 9.0
+**Feature level 268**
+
+* [`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults),
+ [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings):
+ Added a new `web_navigate_to_sent_message` setting to allow users to decide
+ whether to automatically go to conversation where they sent a message.
+
**Feature level 267**
* [`GET /invites`](/api/get-invites),[`POST /invites`](/api/send-invites): Added
diff --git a/version.py b/version.py
index 76d75e88e48..c6afe0f585e 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 267
+API_FEATURE_LEVEL = 268
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump
diff --git a/web/src/realm_user_settings_defaults.ts b/web/src/realm_user_settings_defaults.ts
index 5dc59965858..166c18192a6 100644
--- a/web/src/realm_user_settings_defaults.ts
+++ b/web/src/realm_user_settings_defaults.ts
@@ -57,6 +57,7 @@ export const realm_default_settings_schema = z.object({
web_home_view: z.string(),
web_line_height_percent: z.number(),
web_mark_read_on_scroll_policy: z.number(),
+ web_navigate_to_sent_message: z.boolean(),
web_stream_unreads_count_display_policy: z.number(),
wildcard_mentions_notify: z.boolean(),
});
diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js
index 868bd7aaf52..2a341c7778e 100644
--- a/web/src/server_events_dispatch.js
+++ b/web/src/server_events_dispatch.js
@@ -719,6 +719,7 @@ export function dispatch_normal_event(event) {
"send_stream_typing_notifications",
"send_private_typing_notifications",
"send_read_receipts",
+ "web_navigate_to_sent_message",
];
const original_home_view = user_settings.web_home_view;
diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts
index 23084dbd888..82400c641ee 100644
--- a/web/src/settings_config.ts
+++ b/web/src/settings_config.ts
@@ -575,6 +575,9 @@ export const preferences_settings_labels = {
web_escape_navigates_to_home_view: $t({defaultMessage: "Escape key navigates to home view"}),
web_font_size_px: $t({defaultMessage: "Message-area font size (px)"}),
web_line_height_percent: $t({defaultMessage: "Message-area line height (%)"}),
+ web_navigate_to_sent_message: $t({
+ defaultMessage: "Automatically go to conversation where you sent a message",
+ }),
};
export const notification_settings_labels = {
diff --git a/web/src/user_settings.ts b/web/src/user_settings.ts
index e4c3a87106c..7158240b582 100644
--- a/web/src/user_settings.ts
+++ b/web/src/user_settings.ts
@@ -76,6 +76,7 @@ export const user_settings_schema = stream_notification_settings_schema
web_home_view: z.enum(["inbox", "recent_topics", "all_messages"]),
web_line_height_percent: z.number(),
web_mark_read_on_scroll_policy: z.number(),
+ web_navigate_to_sent_message: z.boolean(),
web_stream_unreads_count_display_policy: z.number(),
});
export type UserSettings = z.infer<typeof user_settings_schema>;
diff --git a/web/templates/settings/display_settings.hbs b/web/templates/settings/display_settings.hbs
index 0bd9db94562..27b9e07d012 100644
--- a/web/templates/settings/display_settings.hbs
+++ b/web/templates/settings/display_settings.hbs
@@ -139,6 +139,12 @@
label=settings_label.web_escape_navigates_to_home_view
prefix=prefix}}
+ {{> settings_checkbox
+ setting_name="web_navigate_to_sent_message"
+ is_checked=settings_object.web_navigate_to_sent_message
+ label=settings_label.web_navigate_to_sent_message
+ prefix=prefix}}
+
<div class="input-group">
<label for="demote_inactive_streams" class="settings-field-label">{{t "Demote inactive channels" }}
{{> ../help_link_widget link="/help/manage-inactive-channels" }}
diff --git a/web/tests/dispatch.test.js b/web/tests/dispatch.test.js
index 92b263b6693..ea3a120c469 100644
--- a/web/tests/dispatch.test.js
+++ b/web/tests/dispatch.test.js
@@ -1121,6 +1121,11 @@ run_test("user_settings", ({override}) => {
user_settings.email_address_visibility = 3;
dispatch(event);
assert_same(user_settings.email_address_visibility, 5);
+
+ event = event_fixtures.user_settings__web_navigate_to_sent_message;
+ user_settings.web_navigate_to_sent_message = true;
+ dispatch(event);
+ assert_same(user_settings.web_navigate_to_sent_message, false);
});
run_test("update_message (read)", ({override}) => {
diff --git a/web/tests/lib/events.js b/web/tests/lib/events.js
index e0395fcf7af..5ead67fc47e 100644
--- a/web/tests/lib/events.js
+++ b/web/tests/lib/events.js
@@ -1071,6 +1071,13 @@ exports.fixtures = {
value: 1,
},
+ user_settings__web_navigate_to_sent_message: {
+ type: "user_settings",
+ op: "update",
+ property: "web_navigate_to_sent_message",
+ value: false,
+ },
+
user_settings__web_stream_unreads_count_display_policy: {
type: "user_settings",
op: "update",
diff --git a/zerver/migrations/0547_realmuserdefault_web_navigate_to_sent_message_and_more.py b/zerver/migrations/0547_realmuserdefault_web_navigate_to_sent_message_and_more.py
new file mode 100644
index 00000000000..a588fd3e680
--- /dev/null
+++ b/zerver/migrations/0547_realmuserdefault_web_navigate_to_sent_message_and_more.py
@@ -0,0 +1,22 @@
+# Generated by Django 5.0.6 on 2024-07-08 19:22
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("zerver", "0546_rename_huddle_directmessagegroup_and_more"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="realmuserdefault",
+ name="web_navigate_to_sent_message",
+ field=models.BooleanField(default=True),
+ ),
+ migrations.AddField(
+ model_name="userprofile",
+ name="web_navigate_to_sent_message",
+ field=models.BooleanField(default=True),
+ ),
+ ]
diff --git a/zerver/models/users.py b/zerver/models/users.py
index 703d94c37e6..24431db5a53 100644
--- a/zerver/models/users.py
+++ b/zerver/models/users.py
@@ -153,6 +153,10 @@ class UserBaseSettings(models.Model):
default=WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS
)
+ # Setting to control whether to automatically go to the
+ # conversation where message was sent.
+ web_navigate_to_sent_message = models.BooleanField(default=True)
+
### Notifications settings. ###
email_notifications_batching_period_seconds = models.IntegerField(default=120)
@@ -329,6 +333,7 @@ class UserBaseSettings(models.Model):
web_stream_unreads_count_display_policy=int,
web_font_size_px=int,
web_line_height_percent=int,
+ web_navigate_to_sent_message=bool,
)
modern_notification_settings: Dict[str, Any] = dict(
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 71b1e99f9b6..87a9190e422 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -11552,6 +11552,15 @@ paths:
- 4
- 5
example: 1
+ web_navigate_to_sent_message:
+ description: |
+ Web/desktop app setting for whether the user's view should
+ automatically go to the conversation where they sent a message.
+
+ **Changes**: New in Zulip 9.0 (feature level 268). Previously,
+ this behavior was not configurable.
+ type: boolean
+ example: true
encoding:
dense_mode:
contentType: application/json
@@ -11649,6 +11658,8 @@ paths:
contentType: application/json
email_address_visibility:
contentType: application/json
+ web_navigate_to_sent_message:
+ contentType: application/json
responses:
"200":
$ref: "#/components/responses/SuccessIgnoredParameters"
@@ -14473,6 +14484,14 @@ paths:
**Changes**: New in Zulip 5.0 (feature level 105).
email_address_visibility:
$ref: "#/components/schemas/EmailAddressVisibility"
+ web_navigate_to_sent_message:
+ type: boolean
+ description: |
+ Web/desktop app setting for whether the user's view should
+ automatically go to the conversation where they sent a message.
+
+ **Changes**: New in Zulip 9.0 (feature level 268). Previously,
+ this behavior was not configurable.
user_topics:
type: array
description: |
@@ -16853,6 +16872,14 @@ paths:
**Changes**: New in Zulip 5.0 (feature level 105).
email_address_visibility:
$ref: "#/components/schemas/EmailAddressVisibility"
+ web_navigate_to_sent_message:
+ type: boolean
+ description: |
+ Web/desktop app setting for whether the user's view should
+ automatically go to the conversation where they sent a message.
+
+ **Changes**: New in Zulip 9.0 (feature level 268). Previously,
+ this behavior was not configurable.
realm_users:
type: array
description: |
@@ -18140,6 +18167,15 @@ paths:
- 4
- 5
example: 1
+ web_navigate_to_sent_message:
+ description: |
+ Web/desktop app setting for whether the user's view should
+ automatically go to the conversation where they sent a message.
+
+ **Changes**: New in Zulip 9.0 (feature level 268). Previously,
+ this behavior was not configurable.
+ type: boolean
+ example: true
encoding:
twenty_four_hour_time:
contentType: application/json
@@ -18241,6 +18277,8 @@ paths:
contentType: application/json
email_address_visibility:
contentType: application/json
+ web_navigate_to_sent_message:
+ contentType: application/json
responses:
"200":
$ref: "#/components/responses/SuccessIgnoredParameters"
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index e2e1fe44622..8f3b0a18155 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -653,6 +653,7 @@ def update_realm_user_settings_defaults(
email_address_visibility: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.EMAIL_ADDRESS_VISIBILITY_TYPES), default=None
),
+ web_navigate_to_sent_message: Optional[bool] = REQ(json_validator=check_bool, default=None),
) -> HttpResponse:
if notification_sound is not None or email_notifications_batching_period_seconds is not None:
check_settings_values(notification_sound, email_notifications_batching_period_seconds)
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index 96221db4c2b..e4fbfaebd7d 100644
--- a/zerver/views/user_settings.py
+++ b/zerver/views/user_settings.py
@@ -315,6 +315,7 @@ def json_change_settings(
email_address_visibility: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.EMAIL_ADDRESS_VISIBILITY_TYPES), default=None
),
+ web_navigate_to_sent_message: Optional[bool] = REQ(json_validator=check_bool, default=None),
) -> HttpResponse:
if (
default_language is not None