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.

ui_init: Pass fetch_event_types to skip unused stream data on reload.

Aman Agrawal19bc668fc508
diff --git a/docs/subsystems/events-system.md b/docs/subsystems/events-system.md
index ef3a2571fe8..c6b3c684423 100644
--- a/docs/subsystems/events-system.md
+++ b/docs/subsystems/events-system.md
@@ -424,7 +424,11 @@ to make sure we handle backwards-compatibility properly.
documentation](../documentation/api.md), being careful to bump
`API_FEATURE_LEVEL` and include a `**Changes**` entry in the updated
`GET /events` API documentation. It's also a good idea to and open
- issues with the mobile and terminal projects to notify them.
+ issues with the mobile and terminal projects to notify them. If the
+ web app should receive the new event type's initial state on browser
+ reload, add it to `FETCH_EVENT_TYPES` in
+ `web/src/server_event_types.ts`, which the web app passes as
+ `fetch_event_types` to `/register`.
- If we're making changes that could confuse existing client app logic
that parses events (e.g., changing the type/meaning of an existing
field, or removing a field), we need to be very careful, since Zulip
diff --git a/web/src/server_event_types.ts b/web/src/server_event_types.ts
index 9ecac0b29e4..8950716cfb9 100644
--- a/web/src/server_event_types.ts
+++ b/web/src/server_event_types.ts
@@ -2,6 +2,54 @@ import * as z from "zod/mini";
import {group_setting_value_schema, topic_link_schema} from "./types.ts";
+// Event types the web app requests from /register via fetch_event_types.
+// Excludes "stream" — the web app doesn't use state["streams"]; it
+// relies on "subscription" data instead.
+// Keep in sync with want() calls in zerver/lib/events.py.
+export const FETCH_EVENT_TYPES: string[] = [
+ "alert_words",
+ "channel_folders",
+ "custom_profile_fields",
+ "default_stream_groups",
+ "default_streams",
+ "device",
+ "drafts",
+ "giphy",
+ "klipy",
+ "message",
+ "muted_topics",
+ "muted_users",
+ "navigation_views",
+ "onboarding_steps",
+ "presence",
+ "realm",
+ "realm_billing",
+ "realm_bot",
+ "realm_domains",
+ "realm_embedded_bots",
+ "realm_emoji",
+ "realm_filters",
+ "realm_incoming_webhook_bots",
+ "realm_linkifiers",
+ "realm_playgrounds",
+ "realm_user",
+ "realm_user_groups",
+ "realm_user_settings_defaults",
+ "recent_private_conversations",
+ "reminders",
+ "saved_snippets",
+ "scheduled_messages",
+ "starred_messages",
+ "stop_words",
+ "subscription",
+ "tenor",
+ "update_message_flags",
+ "user_settings",
+ "user_status",
+ "user_topic",
+ "video_calls",
+];
+
export const user_group_update_event_schema = z.object({
id: z.number(),
type: z.literal("user_group"),
diff --git a/web/src/ui_init.js b/web/src/ui_init.js
index 8443a5d9f17..7cbc73bfd98 100644
--- a/web/src/ui_init.js
+++ b/web/src/ui_init.js
@@ -117,6 +117,7 @@ import * as scheduled_messages_ui from "./scheduled_messages_ui.ts";
import * as scroll_bar from "./scroll_bar.ts";
import * as scroll_util from "./scroll_util.ts";
import * as search from "./search.ts";
+import {FETCH_EVENT_TYPES} from "./server_event_types.ts";
import * as server_events from "./server_events.js";
import * as server_events_state from "./server_events_state.ts";
import * as settings from "./settings.ts";
@@ -851,6 +852,7 @@ $(() => {
slim_presence: true,
include_subscribers: "partial",
presence_history_limit_days: page_params.presence_history_limit_days_for_web_app,
+ fetch_event_types: JSON.stringify(FETCH_EVENT_TYPES),
client_capabilities: JSON.stringify({
notification_settings_null: true,
bulk_message_deletion: true,