user_settings: Add web_mark_read_on_scroll_policy field.

This is a backend change that will help support the new
`Mark messages as read on scroll` user setting.
This commit is contained in:
Joelute 2023-04-05 15:35:47 -04:00 committed by Tim Abbott
parent 82a805e286
commit afbd0a9b43
10 changed files with 127 additions and 2 deletions

View File

@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 7.0 ## Changes in Zulip 7.0
**Feature level 175**
* [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings),
[`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults):
Added new user setting `web_mark_read_on_scroll_policy` . This determines whether to mark
messages as read or not as the client scrolls through their feed.
**Feature level 174**: **Feature level 174**:
* [`POST /typing`](/api/set-typing-status), [`POST /messages`](/api/send-message): * [`POST /typing`](/api/set-typing-status), [`POST /messages`](/api/send-message):

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the # Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**" # new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`. # entries in the endpoint's documentation in `zulip.yaml`.
API_FEATURE_LEVEL = 174 API_FEATURE_LEVEL = 175
# Bump the minor PROVISION_VERSION to indicate that folks should provision # 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 # only when going from an old version of the code to a newer version. Bump

View File

@ -0,0 +1,22 @@
# Generated by Django 4.1.7 on 2023-04-05 01:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0437_remove_realm_authentication_methods"),
]
operations = [
migrations.AddField(
model_name="realmuserdefault",
name="web_mark_read_on_scroll_policy",
field=models.SmallIntegerField(default=1),
),
migrations.AddField(
model_name="userprofile",
name="web_mark_read_on_scroll_policy",
field=models.SmallIntegerField(default=1),
),
]

View File

@ -1574,6 +1574,21 @@ class UserBaseSettings(models.Model):
] ]
demote_inactive_streams = models.PositiveSmallIntegerField(default=DEMOTE_STREAMS_AUTOMATIC) demote_inactive_streams = models.PositiveSmallIntegerField(default=DEMOTE_STREAMS_AUTOMATIC)
# UI setting controlling whether or not the Zulip web app will
# mark messages as read as it scrolls through the feed.
MARK_READ_ON_SCROLL_ALWAYS = 1
MARK_READ_ON_SCROLL_CONVERSATION_ONLY = 2
MARK_READ_ON_SCROLL_NEVER = 3
WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES = [
MARK_READ_ON_SCROLL_ALWAYS,
MARK_READ_ON_SCROLL_CONVERSATION_ONLY,
MARK_READ_ON_SCROLL_NEVER,
]
web_mark_read_on_scroll_policy = models.SmallIntegerField(default=MARK_READ_ON_SCROLL_ALWAYS)
# Emoji sets # Emoji sets
GOOGLE_EMOJISET = "google" GOOGLE_EMOJISET = "google"
GOOGLE_BLOB_EMOJISET = "google-blob" GOOGLE_BLOB_EMOJISET = "google-blob"
@ -1731,6 +1746,7 @@ class UserBaseSettings(models.Model):
send_private_typing_notifications=bool, send_private_typing_notifications=bool,
send_read_receipts=bool, send_read_receipts=bool,
send_stream_typing_notifications=bool, send_stream_typing_notifications=bool,
web_mark_read_on_scroll_policy=int,
user_list_style=int, user_list_style=int,
) )

View File

@ -9089,6 +9089,25 @@ paths:
schema: schema:
type: boolean type: boolean
example: true example: true
- name: web_mark_read_on_scroll_policy
in: query
description: |
Whether or not to mark messages as read when the client scrolls through their
feed.
- 1 - Always
- 2 - Only in conversation views
- 3 - Never
**Changes**: New in Zulip 7.0 (feature level 175). Previously, the app behaved
like the "Always" setting, without any way to configure this.
schema:
type: integer
enum:
- 1
- 2
- 3
example: 1
- name: color_scheme - name: color_scheme
in: query in: query
description: | description: |
@ -11132,6 +11151,18 @@ paths:
description: | description: |
This setting has no effect at present. It is reserved for use in controlling This setting has no effect at present. It is reserved for use in controlling
the default font size in Zulip. the default font size in Zulip.
web_mark_read_on_scroll_policy:
type: integer
description: |
Whether or not to mark messages as read when the client scrolls through their
feed.
- 1 - Always
- 2 - Only in conversation views
- 3 - Never
**Changes**: New in Zulip 7.0 (feature level 175). Previously, the app behaved
like the "Always" setting, without any way to configure this.
starred_message_counts: starred_message_counts:
type: boolean type: boolean
description: | description: |
@ -13085,6 +13116,18 @@ paths:
description: | description: |
This setting has no effect at present. It is reserved for use in This setting has no effect at present. It is reserved for use in
controlling the default font size in Zulip. controlling the default font size in Zulip.
web_mark_read_on_scroll_policy:
type: integer
description: |
Whether or not to mark messages as read when the client scrolls through their
feed.
- 1 - Always
- 2 - Only in conversation views
- 3 - Never
**Changes**: New in Zulip 7.0 (feature level 175). Previously, the app behaved
like the "Always" setting, without any way to configure this.
starred_message_counts: starred_message_counts:
type: boolean type: boolean
description: | description: |
@ -14030,6 +14073,25 @@ paths:
schema: schema:
type: boolean type: boolean
example: true example: true
- name: web_mark_read_on_scroll_policy
in: query
description: |
Whether or not to mark messages as read when the client scrolls through their
feed.
- 1 - Always
- 2 - Only in conversation views
- 3 - Never
**Changes**: New in Zulip 7.0 (feature level 175). Previously, the app behaved
like the "Always" setting, without any way to configure this.
schema:
type: integer
enum:
- 1
- 2
- 3
example: 1
- name: starred_message_counts - name: starred_message_counts
in: query in: query
description: | description: |

View File

@ -2715,6 +2715,7 @@ class RealmPropertyActionTest(BaseAction):
default_view=["recent_topics", "all_messages"], default_view=["recent_topics", "all_messages"],
emojiset=[emojiset["key"] for emojiset in RealmUserDefault.emojiset_choices()], emojiset=[emojiset["key"] for emojiset in RealmUserDefault.emojiset_choices()],
demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES, demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES,
web_mark_read_on_scroll_policy=UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES,
user_list_style=UserProfile.USER_LIST_STYLE_CHOICES, user_list_style=UserProfile.USER_LIST_STYLE_CHOICES,
desktop_icon_count_display=[1, 2, 3], desktop_icon_count_display=[1, 2, 3],
notification_sound=["zulip", "ding"], notification_sound=["zulip", "ding"],
@ -2791,6 +2792,7 @@ class UserDisplayActionTest(BaseAction):
default_language=["es", "de", "en"], default_language=["es", "de", "en"],
default_view=["all_messages", "recent_topics"], default_view=["all_messages", "recent_topics"],
demote_inactive_streams=[2, 3, 1], demote_inactive_streams=[2, 3, 1],
web_mark_read_on_scroll_policy=[2, 3, 1],
user_list_style=[1, 2, 3], user_list_style=[1, 2, 3],
color_scheme=[2, 3, 1], color_scheme=[2, 3, 1],
email_address_visibility=[5, 4, 1, 2, 3], email_address_visibility=[5, 4, 1, 2, 3],

View File

@ -1237,6 +1237,7 @@ class RealmAPITest(ZulipTestCase):
default_view=["recent_topics", "all_messages"], default_view=["recent_topics", "all_messages"],
emojiset=[emojiset["key"] for emojiset in RealmUserDefault.emojiset_choices()], emojiset=[emojiset["key"] for emojiset in RealmUserDefault.emojiset_choices()],
demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES, demote_inactive_streams=UserProfile.DEMOTE_STREAMS_CHOICES,
web_mark_read_on_scroll_policy=UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES,
user_list_style=UserProfile.USER_LIST_STYLE_CHOICES, user_list_style=UserProfile.USER_LIST_STYLE_CHOICES,
desktop_icon_count_display=[1, 2, 3], desktop_icon_count_display=[1, 2, 3],
notification_sound=["zulip", "ding"], notification_sound=["zulip", "ding"],

View File

@ -356,6 +356,7 @@ class ChangeSettingsTest(ZulipTestCase):
emojiset="google", emojiset="google",
timezone="America/Denver", timezone="America/Denver",
demote_inactive_streams=2, demote_inactive_streams=2,
web_mark_read_on_scroll_policy=2,
user_list_style=2, user_list_style=2,
color_scheme=2, color_scheme=2,
email_notifications_batching_period_seconds=100, email_notifications_batching_period_seconds=100,
@ -371,7 +372,12 @@ class ChangeSettingsTest(ZulipTestCase):
if test_value is None: if test_value is None:
raise AssertionError(f"No test created for {setting_name}") raise AssertionError(f"No test created for {setting_name}")
if setting_name not in ["demote_inactive_streams", "user_list_style", "color_scheme"]: if setting_name not in [
"demote_inactive_streams",
"user_list_style",
"color_scheme",
"web_mark_read_on_scroll_policy",
]:
data = {setting_name: test_value} data = {setting_name: test_value}
else: else:
data = {setting_name: orjson.dumps(test_value).decode()} data = {setting_name: orjson.dumps(test_value).decode()}
@ -397,6 +403,7 @@ class ChangeSettingsTest(ZulipTestCase):
emojiset="apple", emojiset="apple",
timezone="invalid_US/Mountain", timezone="invalid_US/Mountain",
demote_inactive_streams=10, demote_inactive_streams=10,
web_mark_read_on_scroll_policy=10,
user_list_style=10, user_list_style=10,
color_scheme=10, color_scheme=10,
notification_sound="invalid_sound", notification_sound="invalid_sound",

View File

@ -398,6 +398,10 @@ def update_realm_user_settings_defaults(
request: HttpRequest, request: HttpRequest,
user_profile: UserProfile, user_profile: UserProfile,
dense_mode: Optional[bool] = REQ(json_validator=check_bool, default=None), dense_mode: Optional[bool] = REQ(json_validator=check_bool, default=None),
web_mark_read_on_scroll_policy: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES),
default=None,
),
starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None), starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None),
fluid_layout_width: Optional[bool] = REQ(json_validator=check_bool, default=None), fluid_layout_width: Optional[bool] = REQ(json_validator=check_bool, default=None),
high_contrast_mode: Optional[bool] = REQ(json_validator=check_bool, default=None), high_contrast_mode: Optional[bool] = REQ(json_validator=check_bool, default=None),

View File

@ -155,6 +155,10 @@ def json_change_settings(
new_password: Optional[str] = REQ(default=None), new_password: Optional[str] = REQ(default=None),
twenty_four_hour_time: Optional[bool] = REQ(json_validator=check_bool, default=None), twenty_four_hour_time: Optional[bool] = REQ(json_validator=check_bool, default=None),
dense_mode: Optional[bool] = REQ(json_validator=check_bool, default=None), dense_mode: Optional[bool] = REQ(json_validator=check_bool, default=None),
web_mark_read_on_scroll_policy: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.WEB_MARK_READ_ON_SCROLL_POLICY_CHOICES),
default=None,
),
starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None), starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None),
fluid_layout_width: Optional[bool] = REQ(json_validator=check_bool, default=None), fluid_layout_width: Optional[bool] = REQ(json_validator=check_bool, default=None),
high_contrast_mode: Optional[bool] = REQ(json_validator=check_bool, default=None), high_contrast_mode: Optional[bool] = REQ(json_validator=check_bool, default=None),