From b21053f3ef51b2e3f04cf790a9c41e9c8fd6f6bd Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 27 Oct 2020 18:38:56 -0700 Subject: [PATCH] initialDataTypes: Add `RawInitialData` and start populating. Greg points out [1] that it's time we start keeping track of a type for our initial data pre-transformation, since we're about to start transforming it. Here, start very small by saying what we expect `realm_users` and two of its friends to look like. We grab those expectations from the `avatar_url` field on `User` and on `CrossRealmBot`. [1] https://github.com/zulip/zulip-mobile/pull/4230#discussion_r513100837 --- src/api/initialDataTypes.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/api/initialDataTypes.js b/src/api/initialDataTypes.js index 5ff6a77fc58..fd7987ea75c 100644 --- a/src/api/initialDataTypes.js +++ b/src/api/initialDataTypes.js @@ -100,6 +100,14 @@ export type InitialDataRealmFilters = {| realm_filters: RealmFilter[], |}; +// TODO: Make complete and exact. +export type RawInitialDataRealmUser = { + realm_users: Array<{| ...User, avatar_url: string | null |}>, + realm_non_active_users: Array<{| ...User, avatar_url: string | null |}>, + cross_realm_bots: Array<{| ...CrossRealmBot, avatar_url: string | void | null |}>, + ... +}; + export type InitialDataRealmUser = {| avatar_source: 'G', avatar_url: string | null, @@ -280,7 +288,17 @@ export type InitialDataUserStatus = {| user_status?: UserStatusMapObject, |}; -// Initial data snapshot sent in response to a `/register` request. +// Initial data snapshot sent in response to a `/register` request, +// before validation and transformation. +// +// TODO: Make complete and exact. +export type RawInitialData = { + ...RawInitialDataRealmUser, + ... +}; + +// Initial data snapshot sent in response to a `/register` request, +// after validation and transformation. export type InitialData = {| // The server sends different subsets of the full available data, // depending on what event types the client subscribes to with the