diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js --- a/lib/reducers/thread-reducer.js +++ b/lib/reducers/thread-reducer.js @@ -94,16 +94,10 @@ { type: 'remove_all', }, - ...Object.keys(newThreadInfos).map((id: string) => { - invariant( - newThreadInfos[id].minimallyEncoded, - 'newThreadInfos must be minimallyEncoded for current clients', - ); - return { - type: 'replace', - payload: { id, threadInfo: newThreadInfos[id] }, - }; - }), + ...Object.keys(newThreadInfos).map((id: string) => ({ + type: 'replace', + payload: { id, threadInfo: newThreadInfos[id] }, + })), ]; const updatedThreadStore = processThreadStoreOperations( state, diff --git a/lib/types/socket-types.js b/lib/types/socket-types.js --- a/lib/types/socket-types.js +++ b/lib/types/socket-types.js @@ -33,7 +33,10 @@ type ClientClientResponse, } from './request-types.js'; import type { SessionState, SessionIdentification } from './session-types.js'; -import { type RawThreadInfos } from './thread-types.js'; +import type { + RawThreadInfos, + MinimallyEncodedRawThreadInfos, +} from './thread-types.js'; import { type ClientUpdatesResult, type ClientUpdatesResultWithUserInfos, @@ -184,41 +187,42 @@ export const fullStateSyncActionType = 'FULL_STATE_SYNC'; export type BaseFullStateSync = { +messagesResult: MessagesResponse, - +threadInfos: RawThreadInfos, +rawEntryInfos: $ReadOnlyArray, +userInfos: $ReadOnlyArray, +updatesCurrentAsOf: number, }; const baseFullStateSyncValidator = tShape({ messagesResult: messagesResponseValidator, - threadInfos: t.dict(tID, rawThreadInfoValidator), rawEntryInfos: t.list(rawEntryInfoValidator), userInfos: t.list(userInfoValidator), updatesCurrentAsOf: t.Number, }); -export type ClientFullStateSync = { +export type ClientFullStateSync = $ReadOnly<{ ...BaseFullStateSync, + +threadInfos: MinimallyEncodedRawThreadInfos, +currentUserInfo: CurrentUserInfo, -}; -export type StateSyncFullActionPayload = { +}>; +export type StateSyncFullActionPayload = $ReadOnly<{ ...ClientFullStateSync, +calendarQuery: CalendarQuery, +keyserverID: string, -}; -export type ClientStateSyncFullSocketPayload = { +}>; +export type ClientStateSyncFullSocketPayload = $ReadOnly<{ ...ClientFullStateSync, +type: 0, // Included iff client is using sessionIdentifierTypes.BODY_SESSION_ID +sessionID?: string, -}; +}>; -export type ServerFullStateSync = { +export type ServerFullStateSync = $ReadOnly<{ ...BaseFullStateSync, + +threadInfos: RawThreadInfos, +currentUserInfo: CurrentUserInfo, -}; +}>; const serverFullStateSyncValidator = tShape({ ...baseFullStateSyncValidator.meta.props, + threadInfos: t.dict(tID, rawThreadInfoValidator), currentUserInfo: currentUserInfoValidator, });