Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream: Move subscriber_count to api_stream_schema.
Evy Kassirer7167150a8758
diff --git a/web/src/stream_data.ts b/web/src/stream_data.tsindex aefb018a998..e33b95c6be5 100644--- a/web/src/stream_data.ts+++ b/web/src/stream_data.ts@@ -14,12 +14,11 @@ import * as settings_config from "./settings_config.ts";import * as settings_data from "./settings_data.ts";import type {CurrentUser, GroupSettingValue, StateData} from "./state_data.ts";import {current_user, realm} from "./state_data.ts";-import type {StreamPermissionGroupSetting, StreamTopicsPolicy} from "./stream_types.ts";+import type {APIStream, StreamPermissionGroupSetting, StreamTopicsPolicy} from "./stream_types.ts";import * as sub_store from "./sub_store.ts";import type {ApiStreamSubscription,NeverSubscribedStream,- Stream,StreamSpecificNotificationSettings,StreamSubscription,} from "./sub_store.ts";@@ -1037,12 +1036,11 @@ export async function maybe_fetch_is_user_subscribed();}-export function create_streams(streams: Stream[]): void {+export function create_streams(streams: APIStream[]): void {for (const stream of streams) {// We handle subscriber stuff in other events.const attrs = {- stream_weekly_traffic: null,subscribers: [],...stream,};diff --git a/web/src/stream_types.ts b/web/src/stream_types.tsindex dda6f0ed71b..ce62c4f45c1 100644--- a/web/src/stream_types.ts+++ b/web/src/stream_types.ts@@ -60,11 +60,6 @@ export const stream_schema = z.object({rendered_description: z.string(),stream_id: z.number(),stream_post_policy: z.enum(StreamPostPolicy),- // This field is stripped from subscriber objects when loading data- // from the server. Always use `peer_data.get_subscriber_count` to- // access channel subscriber counts, and see its comments for notes- // about the possibility of inaccuracy in the presence of certain races.- subscriber_count: z.optional(z.number()),topics_policy: stream_topics_policy_schema,});@@ -79,7 +74,13 @@ export const stream_specific_notification_settings_schema = z.object({export const api_stream_schema = z.object({...stream_schema.shape,stream_weekly_traffic: z.nullable(z.number()),+ // This field is stripped from subscriber objects when loading data+ // from the server. Always use `peer_data.get_subscriber_count` to+ // access channel subscriber counts, and see its comments for notes+ // about the possibility of inaccuracy in the presence of certain races.+ subscriber_count: z.number(),});+export type APIStream = z.infer<typeof api_stream_schema>;export const never_subscribed_stream_schema = z.object({...api_stream_schema.shape,