diff --git a/keyserver/src/creators/update-creator.js b/keyserver/src/creators/update-creator.js --- a/keyserver/src/creators/update-creator.js +++ b/keyserver/src/creators/update-creator.js @@ -31,7 +31,7 @@ redisMessageTypes, type NewUpdatesRedisMessage, } from 'lib/types/redis-types.js'; -import type { RawThreadInfos } from 'lib/types/thread-types'; +import type { MixedRawThreadInfos } from 'lib/types/thread-types'; import { type ServerUpdateInfo, type UpdateData, @@ -92,7 +92,7 @@ viewer: Viewer, calendarQuery: ?CalendarQuery, updatesForCurrentSession?: UpdatesForCurrentSession, - threadInfos: RawThreadInfos, + threadInfos: MixedRawThreadInfos, }; const defaultUpdateCreationResult = { viewerUpdates: [], userInfos: {} }; const sortFunction = ( diff --git a/keyserver/src/fetchers/thread-fetchers.js b/keyserver/src/fetchers/thread-fetchers.js --- a/keyserver/src/fetchers/thread-fetchers.js +++ b/keyserver/src/fetchers/thread-fetchers.js @@ -16,7 +16,7 @@ import { threadTypes, type ThreadType } from 'lib/types/thread-types-enum.js'; import { type ServerThreadInfo, - type RawThreadInfos, + type MixedRawThreadInfos, type LegacyRawThreadInfo, } from 'lib/types/thread-types.js'; import { ServerError } from 'lib/utils/errors.js'; @@ -246,7 +246,7 @@ } export type FetchThreadInfosResult = { - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, }; async function fetchThreadInfos( diff --git a/keyserver/src/shared/state-sync/threads-state-sync-spec.js b/keyserver/src/shared/state-sync/threads-state-sync-spec.js --- a/keyserver/src/shared/state-sync/threads-state-sync-spec.js +++ b/keyserver/src/shared/state-sync/threads-state-sync-spec.js @@ -5,7 +5,7 @@ import type { RawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ClientThreadInconsistencyReportCreationRequest } from 'lib/types/report-types.js'; import { - type RawThreadInfos, + type MixedRawThreadInfos, type LegacyRawThreadInfo, } from 'lib/types/thread-types.js'; import { hash, combineUnorderedHashes, values } from 'lib/utils/objects.js'; @@ -16,8 +16,8 @@ import { validateOutput } from '../../utils/validation-utils.js'; export const threadsStateSyncSpec: ServerStateSyncSpec< - RawThreadInfos, - RawThreadInfos, + MixedRawThreadInfos, + MixedRawThreadInfos, LegacyRawThreadInfo | RawThreadInfo, $ReadOnlyArray, > = Object.freeze({ @@ -41,7 +41,7 @@ return result.threadInfos; } -function getServerInfosHash(infos: RawThreadInfos) { +function getServerInfosHash(infos: MixedRawThreadInfos) { return combineUnorderedHashes(values(infos).map(getServerInfoHash)); } diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js --- a/lib/reducers/message-reducer.js +++ b/lib/reducers/message-reducer.js @@ -99,7 +99,7 @@ import type { LegacyRawThreadInfo, MinimallyEncodedRawThreadInfos, - RawThreadInfos, + MixedRawThreadInfos, } from '../types/thread-types.js'; import { type ClientUpdateInfo, @@ -151,7 +151,7 @@ messageInfos: $ReadOnlyArray, truncationStatus: { [threadID: string]: MessageTruncationStatus }, currentAsOf: { +[keyserverID: string]: number }, - threadInfos: RawThreadInfos, + threadInfos: MixedRawThreadInfos, ): FreshMessageStoreResult { const unshimmed = unshimMessageInfos(messageInfos); const orderedMessageInfos = sortMessageInfoList(unshimmed); diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js --- a/lib/selectors/thread-selectors.js +++ b/lib/selectors/thread-selectors.js @@ -51,7 +51,7 @@ SidebarInfo, RelativeMemberInfo, ThreadInfo, - RawThreadInfos, + MixedRawThreadInfos, MinimallyEncodedRawThreadInfos, } from '../types/thread-types.js'; import { dateString, dateFromString } from '../utils/date-utils.js'; @@ -378,7 +378,7 @@ function mostRecentlyReadThread( messageStore: MessageStore, - threadInfos: RawThreadInfos, + threadInfos: MixedRawThreadInfos, ): ?string { let mostRecent = null; for (const threadID in threadInfos) { diff --git a/lib/shared/state-sync/threads-state-sync-spec.js b/lib/shared/state-sync/threads-state-sync-spec.js --- a/lib/shared/state-sync/threads-state-sync-spec.js +++ b/lib/shared/state-sync/threads-state-sync-spec.js @@ -12,7 +12,7 @@ } from '../../types/report-types.js'; import type { ProcessServerRequestAction } from '../../types/request-types.js'; import { - type RawThreadInfos, + type MixedRawThreadInfos, type LegacyRawThreadInfo, } from '../../types/thread-types.js'; import { actionLogger } from '../../utils/action-logger.js'; @@ -25,7 +25,7 @@ const selector: ( state: AppState, ) => BoundStateSyncSpec< - RawThreadInfos, + MixedRawThreadInfos, LegacyRawThreadInfo | RawThreadInfo, $ReadOnlyArray, > = createSelector( @@ -44,7 +44,7 @@ ); export const threadsStateSyncSpec: StateSyncSpec< - RawThreadInfos, + MixedRawThreadInfos, LegacyRawThreadInfo | RawThreadInfo, $ReadOnlyArray, > = Object.freeze({ @@ -56,8 +56,8 @@ }, findStoreInconsistencies( action: ProcessServerRequestAction, - beforeStateCheck: RawThreadInfos, - afterStateCheck: RawThreadInfos, + beforeStateCheck: MixedRawThreadInfos, + afterStateCheck: MixedRawThreadInfos, ) { if (_isEqual(beforeStateCheck)(afterStateCheck)) { return emptyArray; diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -97,7 +97,7 @@ UserProfileThreadInfo, RelativeMemberInfo, ThreadInfo, - RawThreadInfos, + MixedRawThreadInfos, } from '../types/thread-types.js'; import { updateTypes } from '../types/update-types-enum.js'; import { type ClientUpdateInfo } from '../types/update-types.js'; @@ -1809,7 +1809,7 @@ ]); } -function assertAllThreadInfosAreLegacy(rawThreadInfos: RawThreadInfos): { +function assertAllThreadInfosAreLegacy(rawThreadInfos: MixedRawThreadInfos): { [id: string]: LegacyRawThreadInfo, } { return Object.fromEntries( diff --git a/lib/shared/updates/delete-thread-spec.js b/lib/shared/updates/delete-thread-spec.js --- a/lib/shared/updates/delete-thread-spec.js +++ b/lib/shared/updates/delete-thread-spec.js @@ -3,7 +3,7 @@ import t from 'tcomb'; import type { UpdateSpec } from './update-spec.js'; -import type { RawThreadInfos } from '../../types/thread-types.js'; +import type { MixedRawThreadInfos } from '../../types/thread-types.js'; import { updateTypes } from '../../types/update-types-enum.js'; import type { ThreadDeletionRawUpdateInfo, @@ -18,7 +18,7 @@ ThreadDeletionUpdateData, > = Object.freeze({ generateOpsForThreadUpdates( - storeThreadInfos: RawThreadInfos, + storeThreadInfos: MixedRawThreadInfos, update: ThreadDeletionUpdateInfo, ) { if (storeThreadInfos[update.threadID]) { diff --git a/lib/shared/updates/update-spec.js b/lib/shared/updates/update-spec.js --- a/lib/shared/updates/update-spec.js +++ b/lib/shared/updates/update-spec.js @@ -16,7 +16,7 @@ } from '../../types/message-types.js'; import type { MinimallyEncodedRawThreadInfos, - RawThreadInfos, + MixedRawThreadInfos, } from '../../types/thread-types.js'; import type { UpdateType } from '../../types/update-types-enum.js'; import type { @@ -31,7 +31,7 @@ } from '../../types/user-types.js'; export type UpdateInfosRawData = { - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, +messageInfosResult: ?FetchMessageInfosResult, +calendarResult: ?FetchEntryInfosBase, +entryInfosResult: ?RawEntryInfos, diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -16,7 +16,7 @@ } from './message-types.js'; import type { PreRequestUserState } from './session-types.js'; import { - type RawThreadInfos, + type MixedRawThreadInfos, type MinimallyEncodedRawThreadInfos, } from './thread-types.js'; import { @@ -72,7 +72,7 @@ +rawMessageInfos: $ReadOnlyArray, +currentUserInfo: LoggedInUserInfo, +cookieChange: { - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, +userInfos: $ReadOnlyArray, }, }; @@ -147,7 +147,7 @@ +rawEntryInfos?: ?$ReadOnlyArray, +serverTime: number, +cookieChange: { - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, +userInfos: $ReadOnlyArray, }, +notAcknowledgedPolicies?: $ReadOnlyArray, @@ -173,7 +173,7 @@ }; export type KeyserverAuthResult = { - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, +currentUserInfo?: ?LoggedInUserInfo, +messagesResult: GenericMessagesResult, +userInfos: $ReadOnlyArray, diff --git a/lib/types/report-types.js b/lib/types/report-types.js --- a/lib/types/report-types.js +++ b/lib/types/report-types.js @@ -7,7 +7,7 @@ import { type RawEntryInfo, type CalendarQuery } from './entry-types.js'; import { type MediaMission } from './media-types.js'; import type { AppState, BaseAction } from './redux-types.js'; -import { type RawThreadInfos } from './thread-types.js'; +import { type MixedRawThreadInfos } from './thread-types.js'; import type { UserInfo, UserInfos } from './user-types.js'; import { tPlatformDetails, tShape } from '../utils/validation-utils.js'; @@ -71,10 +71,10 @@ }; export type ThreadInconsistencyReportShape = { +platformDetails: PlatformDetails, - +beforeAction: RawThreadInfos, + +beforeAction: MixedRawThreadInfos, +action: BaseAction, - +pollResult?: ?RawThreadInfos, - +pushResult: RawThreadInfos, + +pollResult?: ?MixedRawThreadInfos, + +pushResult: MixedRawThreadInfos, +lastActionTypes?: ?$ReadOnlyArray<$PropertyType>, +lastActions?: ?$ReadOnlyArray, +time?: ?number, @@ -139,9 +139,9 @@ export type ClientThreadInconsistencyReportShape = { +platformDetails: PlatformDetails, - +beforeAction: RawThreadInfos, + +beforeAction: MixedRawThreadInfos, +action: BaseAction, - +pushResult: RawThreadInfos, + +pushResult: MixedRawThreadInfos, +lastActions: $ReadOnlyArray, +time: number, }; diff --git a/lib/types/session-types.js b/lib/types/session-types.js --- a/lib/types/session-types.js +++ b/lib/types/session-types.js @@ -4,7 +4,7 @@ import type { LogInActionSource } from './account-types.js'; import type { CalendarQuery } from './entry-types.js'; -import type { RawThreadInfos } from './thread-types.js'; +import type { MixedRawThreadInfos } from './thread-types.js'; import { type UserInfo, type CurrentUserInfo, @@ -37,14 +37,14 @@ export type ServerSessionChange = | { cookieInvalidated: false, - threadInfos: RawThreadInfos, + threadInfos: MixedRawThreadInfos, userInfos: $ReadOnlyArray, sessionID?: null | string, cookie?: string, } | { cookieInvalidated: true, - threadInfos: RawThreadInfos, + threadInfos: MixedRawThreadInfos, userInfos: $ReadOnlyArray, currentUserInfo: LoggedOutUserInfo, sessionID?: null | string, 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 @@ -34,7 +34,7 @@ } from './request-types.js'; import type { SessionState, SessionIdentification } from './session-types.js'; import type { - RawThreadInfos, + MixedRawThreadInfos, MinimallyEncodedRawThreadInfos, } from './thread-types.js'; import { @@ -217,7 +217,7 @@ export type ServerFullStateSync = $ReadOnly<{ ...BaseFullStateSync, - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, +currentUserInfo: CurrentUserInfo, }>; const serverFullStateSyncValidator = tShape({ diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js --- a/lib/types/thread-types.js +++ b/lib/types/thread-types.js @@ -144,7 +144,7 @@ pinnedCount: t.maybe(t.Number), }); -export type RawThreadInfos = { +export type MixedRawThreadInfos = { +[id: string]: LegacyRawThreadInfo | RawThreadInfo, }; export type MinimallyEncodedRawThreadInfos = { @@ -246,7 +246,7 @@ }; export type LegacyThreadStore = { - +threadInfos: RawThreadInfos, + +threadInfos: MixedRawThreadInfos, }; export type ThreadStore = { diff --git a/lib/utils/migration-utils.js b/lib/utils/migration-utils.js --- a/lib/utils/migration-utils.js +++ b/lib/utils/migration-utils.js @@ -25,7 +25,7 @@ threadPermissionPropagationPrefixes, threadPermissionFilterPrefixes, } from '../types/thread-permission-types.js'; -import type { RawThreadInfos } from '../types/thread-types.js'; +import type { MixedRawThreadInfos } from '../types/thread-types.js'; function convertDraftKeyToNewIDSchema(key: string): string { const threadID = key.slice(0, -draftKeySuffix.length); @@ -69,8 +69,8 @@ } function convertThreadStoreThreadInfosToNewIDSchema( - threadStoreThreadInfos: RawThreadInfos, -): RawThreadInfos { + threadStoreThreadInfos: MixedRawThreadInfos, +): MixedRawThreadInfos { return Object.fromEntries( entries(threadStoreThreadInfos).map(([id, threadInfo]) => { invariant( diff --git a/native/redux/client-db-utils.js b/native/redux/client-db-utils.js --- a/native/redux/client-db-utils.js +++ b/native/redux/client-db-utils.js @@ -11,7 +11,7 @@ import type { ClientDBThreadInfo, LegacyRawThreadInfo, - RawThreadInfos, + MixedRawThreadInfos, } from 'lib/types/thread-types.js'; import { translateClientDBMessageInfoToRawMessageInfo, @@ -31,7 +31,7 @@ function updateClientDBThreadStoreThreadInfos( state: AppState, - migrationFunc: RawThreadInfos => RawThreadInfos, + migrationFunc: MixedRawThreadInfos => MixedRawThreadInfos, ): AppState { // Get threads from SQLite `threads` table. const clientDBThreadInfos = commCoreModule.getAllThreadsSync(); @@ -63,7 +63,7 @@ function createUpdateDBOpsForThreadStoreThreadInfos( clientDBThreadInfos: $ReadOnlyArray, - migrationFunc: RawThreadInfos => RawThreadInfos, + migrationFunc: MixedRawThreadInfos => MixedRawThreadInfos, ): $ReadOnlyArray { // Translate `ClientDBThreadInfo`s to `RawThreadInfo`s. const rawThreadInfos = clientDBThreadInfos.map( diff --git a/native/redux/legacy-update-roles-and-permissions.js b/native/redux/legacy-update-roles-and-permissions.js --- a/native/redux/legacy-update-roles-and-permissions.js +++ b/native/redux/legacy-update-roles-and-permissions.js @@ -12,7 +12,7 @@ LegacyRawThreadInfo, ThreadStoreThreadInfos, LegacyMemberInfo, - RawThreadInfos, + MixedRawThreadInfos, } from 'lib/types/thread-types.js'; import { values } from 'lib/utils/objects.js'; @@ -52,8 +52,8 @@ // This migration utility can only be used with LegacyRawThreadInfos function legacyUpdateRolesAndPermissions( - threadStoreInfos: RawThreadInfos, -): RawThreadInfos { + threadStoreInfos: MixedRawThreadInfos, +): MixedRawThreadInfos { const updatedThreadStoreInfos = assertAllThreadInfosAreLegacy({ ...threadStoreInfos, }); diff --git a/native/redux/persist.js b/native/redux/persist.js --- a/native/redux/persist.js +++ b/native/redux/persist.js @@ -76,7 +76,7 @@ import type { ClientDBThreadInfo, LegacyRawThreadInfo, - RawThreadInfos, + MixedRawThreadInfos, } from 'lib/types/thread-types.js'; import { translateClientDBMessageInfoToRawMessageInfo, @@ -994,8 +994,8 @@ ), [61]: (state: AppState) => { const minimallyEncodeThreadInfosFunc = ( - threadStoreInfos: RawThreadInfos, - ): RawThreadInfos => + threadStoreInfos: MixedRawThreadInfos, + ): MixedRawThreadInfos => Object.keys(threadStoreInfos).reduce( ( acc: {