user_settings: Add new `web_stream_unreads_count_display_policy` field.

This is a backend change that will help us support the new "Show unread counts for"
user display setting.
This commit is contained in:
Lalit 2023-04-25 15:59:15 +05:30 committed by Tim Abbott
parent 574a87b87d
commit 2b566c778b
10 changed files with 121 additions and 1 deletions

View File

@ -20,6 +20,14 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 8.0
**Feature level 210**
* [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings),
[`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults):
Added new `web_stream_unreads_count_display_policy` display setting, which controls in
which streams (all/unmuted/none) unread messages count shows up
in left sidebar.
**Feature level 209**
* `PATCH /realm`, [`POST /register`](/api/register-queue),

View File

@ -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 = 209
API_FEATURE_LEVEL = 210
# 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

View File

@ -0,0 +1,22 @@
# Generated by Django 4.2.4 on 2023-08-27 04:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0473_remove_message_non_realm_id_indexes"),
]
operations = [
migrations.AddField(
model_name="realmuserdefault",
name="web_stream_unreads_count_display_policy",
field=models.PositiveSmallIntegerField(default=2),
),
migrations.AddField(
model_name="userprofile",
name="web_stream_unreads_count_display_policy",
field=models.PositiveSmallIntegerField(default=2),
),
]

View File

@ -1568,6 +1568,19 @@ class UserBaseSettings(models.Model):
]
user_list_style = models.PositiveSmallIntegerField(default=USER_LIST_STYLE_WITH_STATUS)
# Show unread counts for
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_ALL_STREAMS = 1
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS = 2
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_NO_STREAMS = 3
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES = [
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_ALL_STREAMS,
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS,
WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_NO_STREAMS,
]
web_stream_unreads_count_display_policy = models.PositiveSmallIntegerField(
default=WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_UNMUTED_STREAMS
)
### Notifications settings. ###
email_notifications_batching_period_seconds = models.IntegerField(default=120)
@ -1710,6 +1723,7 @@ class UserBaseSettings(models.Model):
send_stream_typing_notifications=bool,
web_mark_read_on_scroll_policy=int,
user_list_style=int,
web_stream_unreads_count_display_policy=int,
)
modern_notification_settings: Dict[str, Any] = dict(

View File

@ -9868,6 +9868,25 @@ paths:
- 2
- 3
example: 1
- name: web_stream_unreads_count_display_policy
in: query
description: |
Configuration for which streams should be displayed with a numeric unread count in the left sidebar.
Streams that do not have an unread count will have a simple dot indicator for whether there are any
unread messages.
- 1 - All streams
- 2 - Unmuted streams
- 3 - No streams
**Changes**: New in Zulip 8.0 (feature level 210).
schema:
type: integer
enum:
- 1
- 2
- 3
example: 2
- name: enable_stream_desktop_notifications
in: query
description: |
@ -12116,6 +12135,18 @@ paths:
- 3 - With avatar and status
**Changes**: New in Zulip 6.0 (feature level 141).
web_stream_unreads_count_display_policy:
type: integer
description: |
Configuration for which streams should be displayed with a numeric unread count in the left sidebar.
Streams that do not have an unread count will have a simple dot indicator for whether there are any
unread messages.
- 1 - All streams
- 2 - Unmuted streams
- 3 - No streams
**Changes**: New in Zulip 8.0 (feature level 210).
timezone:
type: string
description: |
@ -14229,6 +14260,18 @@ paths:
- 3 - With avatar and status
**Changes**: New in Zulip 6.0 (feature level 141).
web_stream_unreads_count_display_policy:
type: integer
description: |
Configuration for which streams should be displayed with a numeric unread count in the left sidebar.
Streams that do not have an unread count will have a simple dot indicator for whether there are any
unread messages.
- 1 - All streams
- 2 - Unmuted streams
- 3 - No streams
**Changes**: New in Zulip 8.0 (feature level 210).
enable_stream_desktop_notifications:
type: boolean
description: |
@ -15301,6 +15344,25 @@ paths:
- 2
- 3
example: 1
- name: web_stream_unreads_count_display_policy
in: query
description: |
Configuration for which streams should be displayed with a numeric unread count in the left sidebar.
Streams that do not have an unread count will have a simple dot indicator for whether there are any
unread messages.
- 1 - All streams
- 2 - Unmuted streams
- 3 - No streams
**Changes**: New in Zulip 8.0 (feature level 210).
schema:
type: integer
enum:
- 1
- 2
- 3
example: 2
- name: timezone
in: query
description: |

View File

@ -3092,6 +3092,7 @@ class RealmPropertyActionTest(BaseAction):
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,
web_stream_unreads_count_display_policy=UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES,
desktop_icon_count_display=[1, 2, 3],
notification_sound=["zulip", "ding"],
email_notifications_batching_period_seconds=[120, 300],
@ -3171,6 +3172,7 @@ class UserDisplayActionTest(BaseAction):
demote_inactive_streams=[2, 3, 1],
web_mark_read_on_scroll_policy=[2, 3, 1],
user_list_style=[1, 2, 3],
web_stream_unreads_count_display_policy=[1, 2, 3],
color_scheme=[2, 3, 1],
email_address_visibility=[5, 4, 1, 2, 3],
)

View File

@ -1304,6 +1304,7 @@ class RealmAPITest(ZulipTestCase):
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,
web_stream_unreads_count_display_policy=UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES,
desktop_icon_count_display=[1, 2, 3],
notification_sound=["zulip", "ding"],
email_notifications_batching_period_seconds=[120, 300],

View File

@ -355,6 +355,7 @@ class ChangeSettingsTest(ZulipTestCase):
demote_inactive_streams=2,
web_mark_read_on_scroll_policy=2,
user_list_style=2,
web_stream_unreads_count_display_policy=2,
color_scheme=2,
email_notifications_batching_period_seconds=100,
notification_sound="ding",
@ -374,6 +375,7 @@ class ChangeSettingsTest(ZulipTestCase):
"user_list_style",
"color_scheme",
"web_mark_read_on_scroll_policy",
"web_stream_unreads_count_display_policy",
]:
data = {setting_name: test_value}
else:
@ -402,6 +404,7 @@ class ChangeSettingsTest(ZulipTestCase):
demote_inactive_streams=10,
web_mark_read_on_scroll_policy=10,
user_list_style=10,
web_stream_unreads_count_display_policy=10,
color_scheme=10,
notification_sound="invalid_sound",
desktop_icon_count_display=10,

View File

@ -438,6 +438,10 @@ def update_realm_user_settings_defaults(
default=None,
),
starred_message_counts: Optional[bool] = REQ(json_validator=check_bool, default=None),
web_stream_unreads_count_display_policy: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES),
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),
color_scheme: Optional[int] = REQ(

View File

@ -197,6 +197,10 @@ def json_change_settings(
demote_inactive_streams: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.DEMOTE_STREAMS_CHOICES), default=None
),
web_stream_unreads_count_display_policy: Optional[int] = REQ(
json_validator=check_int_in(UserProfile.WEB_STREAM_UNREADS_COUNT_DISPLAY_POLICY_CHOICES),
default=None,
),
timezone: Optional[str] = REQ(str_validator=check_timezone, default=None),
email_notifications_batching_period_seconds: Optional[int] = REQ(
json_validator=check_int, default=None