Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions src/api/initialDataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,48 @@ import type {
UserStatusMapObject,
} from './apiTypes';

export type InitialDataBase = {|
export type InitialDataBase = $ReadOnly<{|
last_event_id: number,
msg: string,
queue_id: number,
|};
|}>;

export type InitialDataAlertWords = {|
export type InitialDataAlertWords = $ReadOnly<{|
alert_words: string[],
|};
|}>;

export type InitialDataMessage = {|
export type InitialDataMessage = $ReadOnly<{|
max_message_id: number,
|};
|}>;

export type MuteTuple = [string, string];

export type InitialDataMutedTopics = {|
export type InitialDataMutedTopics = $ReadOnly<{|
muted_topics: MuteTuple[],
|};
|}>;

/** Added in server version 4.0, feature level 48 */
export type InitialDataMutedUsers = {|
export type InitialDataMutedUsers = $ReadOnly<{|
muted_users?: MutedUser[],
|};
|}>;

export type InitialDataPresence = {|
export type InitialDataPresence = $ReadOnly<{|
presences: {| [email: string]: UserPresence |},
|};
|}>;

export type AvailableVideoChatProviders = {|
[providerName: string]: {| name: string, id: number |},
|};
export type AvailableVideoChatProviders = $ReadOnly<{|
[providerName: string]: $ReadOnly<{| name: string, id: number |}>,
|}>;

export type InitialDataRealm = {|
export type InitialDataRealm = $ReadOnly<{|
jitsi_server_url?: string,
max_icon_file_size: number,
realm_add_emoji_by_admins_only: boolean,
realm_allow_community_topic_editing: boolean,
realm_allow_edit_history: boolean,
realm_allow_message_deleting: boolean,
realm_allow_message_editing: boolean,
realm_authentication_methods: { GitHub: true, Email: true, Google: true, ... },
realm_authentication_methods: $ReadOnly<{ GitHub: true, Email: true, Google: true, ... }>,
realm_available_video_chat_providers: AvailableVideoChatProviders,
realm_bot_creation_policy: number,
realm_bot_domain: string,
Expand Down Expand Up @@ -99,17 +99,17 @@ export type InitialDataRealm = {|
* https://zulip.com/api/get-server-settings
*/
zulip_feature_level?: number,
|};
|}>;

export type InitialDataRealmEmoji = {|
export type InitialDataRealmEmoji = $ReadOnly<{|
realm_emoji: RealmEmojiById,
|};
|}>;

export type RawInitialDataRealmFilters = {|
export type RawInitialDataRealmFilters = $ReadOnly<{|
// We still request this, since not all servers can provide the
// newer `realm_linkifiers` format.
realm_filters?: RealmFilter[],
|};
realm_filters?: $ReadOnlyArray<RealmFilter>,
|}>;

/**
* The realm_filters/realm_linkifiers data, post-transformation.
Expand All @@ -121,67 +121,67 @@ export type RawInitialDataRealmFilters = {|
*
* See notes on `RealmFilter` and `RealmLinkifier`.
*/
export type InitialDataRealmFilters = {|
realm_filters: RealmFilter[],
|};
export type InitialDataRealmFilters = $ReadOnly<{|
realm_filters: $ReadOnlyArray<RealmFilter>,
|}>;

export type InitialDataRealmLinkifiers = {|
export type InitialDataRealmLinkifiers = $ReadOnly<{|
// Possibly absent: Not all servers can provide this. See
// `InitialDataRealmFilters`.
realm_linkifiers?: RealmLinkifier[],
|};
realm_linkifiers?: $ReadOnlyArray<RealmLinkifier>,
|}>;

export type RawInitialDataRealmUser = {|
export type RawInitialDataRealmUser = $ReadOnly<{|
avatar_source: 'G',
avatar_url: string | null,
avatar_url_medium: string,
can_create_streams: boolean,
cross_realm_bots: Array<{| ...CrossRealmBot, avatar_url?: string | null |}>,
cross_realm_bots: $ReadOnlyArray<{| ...CrossRealmBot, +avatar_url?: string | null |}>,
email: string,
enter_sends: boolean,
full_name: string,
is_admin: boolean,
realm_users: Array<{| ...User, avatar_url?: string | null |}>,
realm_non_active_users: Array<{| ...User, avatar_url?: string | null |}>,
realm_users: $ReadOnlyArray<{| ...User, avatar_url?: string | null |}>,
realm_non_active_users: $ReadOnlyArray<{| ...User, avatar_url?: string | null |}>,
user_id: UserId,
|};
|}>;

export type InitialDataRealmUser = {|
export type InitialDataRealmUser = $ReadOnly<{|
...RawInitialDataRealmUser,
cross_realm_bots: CrossRealmBot[],
realm_non_active_users: User[],
realm_users: User[],
|};
cross_realm_bots: $ReadOnlyArray<CrossRealmBot>,
realm_non_active_users: $ReadOnlyArray<User>,
realm_users: $ReadOnlyArray<User>,
|}>;

export type InitialDataRealmUserGroups = {|
export type InitialDataRealmUserGroups = $ReadOnly<{|
/**
* Absent in servers prior to v1.8.0-rc1~2711 (or thereabouts).
*/
realm_user_groups?: UserGroup[],
|};
realm_user_groups?: $ReadOnlyArray<UserGroup>,
|}>;

export type InitialDataRecentPmConversations = {|
export type InitialDataRecentPmConversations = $ReadOnly<{|
// * Added in server commit 2.1-dev-384-g4c3c669b41.
// * `user_id` fields are sorted as of commit 2.2-dev-53-g405a529340, which
// was backported to 2.1.1-50-gd452ad31e0 -- meaning that they are _not_
// sorted in either v2.1.0 or v2.1.1.
recent_private_conversations?: RecentPrivateConversation[],
|};
recent_private_conversations?: $ReadOnlyArray<RecentPrivateConversation>,
|}>;

type NeverSubscribedStream = {|
type NeverSubscribedStream = $ReadOnly<{|
description: string,
invite_only: boolean,
is_old_stream: boolean,
name: string,
stream_id: number,
|};
|}>;

export type InitialDataStream = {|
streams: Stream[],
|};
export type InitialDataStream = $ReadOnly<{|
streams: $ReadOnlyArray<Stream>,
|}>;

export type InitialDataSubscription = {|
never_subscribed: NeverSubscribedStream[],
export type InitialDataSubscription = $ReadOnly<{|
never_subscribed: $ReadOnlyArray<NeverSubscribedStream>,

/**
* All servers, at least as far back as zulip/zulip@7a930af, in
Expand All @@ -192,24 +192,24 @@ export type InitialDataSubscription = {|
* This investigation is reported at
* https://github.com/zulip/zulip-mobile/pull/4046#discussion_r414901766.
*/
subscriptions: Subscription[],
subscriptions: $ReadOnlyArray<Subscription>,

unsubscribed: Subscription[],
|};
unsubscribed: $ReadOnlyArray<Subscription>,
|}>;

export type InitialDataUpdateDisplaySettings = {|
export type InitialDataUpdateDisplaySettings = $ReadOnly<{|
default_language: string,
emojiset: string,
emojiset_choices: {| [string]: string |},
emojiset_choices: $ReadOnly<{| [string]: string |}>,
high_contrast_mode: boolean,
left_side_userlist: boolean,
night_mode: boolean,
timezone: string,
translate_emoticons: boolean,
twenty_four_hour_time: boolean,
|};
|}>;

export type InitialDataUpdateGlobalNotifications = {|
export type InitialDataUpdateGlobalNotifications = $ReadOnly<{|
default_desktop_notifications: boolean,
enable_desktop_notifications: boolean,
enable_digest_emails: boolean,
Expand All @@ -224,29 +224,29 @@ export type InitialDataUpdateGlobalNotifications = {|
message_content_in_email_notifications: boolean,
pm_content_in_desktop_notifications: boolean,
realm_name_in_notifications: boolean,
|};
|}>;

export type StreamUnreadItem = {|
export type StreamUnreadItem = $ReadOnly<{|
stream_id: number,
topic: string,

// Sorted.
unread_message_ids: number[],
unread_message_ids: $ReadOnlyArray<number>,

/** All distinct senders of these messages; sorted. */
// sender_ids: UserId[],
|};
|}>;

export type HuddlesUnreadItem = {|
export type HuddlesUnreadItem = $ReadOnly<{|
/** All users, including self; numerically sorted, comma-separated. */
user_ids_string: string,

// Sorted.
unread_message_ids: number[],
|};
unread_message_ids: $ReadOnlyArray<number>,
|}>;

/** The unreads in a 1:1 PM thread, as represented in `unread_msgs`. */
export type PmsUnreadItem = {|
export type PmsUnreadItem = $ReadOnly<{|
/**
* Misnamed; really the *other* user, or self for a self-PM.
*
Expand All @@ -259,8 +259,8 @@ export type PmsUnreadItem = {|
sender_id: UserId,

// Sorted.
unread_message_ids: number[],
|};
unread_message_ids: $ReadOnlyArray<number>,
|}>;

/** Initial data for `update_message_flags` events. */
export type InitialDataUpdateMessageFlags = {|
Expand Down
Loading