diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js --- a/lib/selectors/chat-selectors.js +++ b/lib/selectors/chat-selectors.js @@ -294,7 +294,7 @@ +startsCluster: boolean, endsCluster: boolean, +robotext: EntityText, - +threadCreatedFromMessage: ?ThreadInfo, + +threadCreatedFromMessage: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +reactions: ReactionInfo, }; export type ChatMessageInfoItem = @@ -307,7 +307,7 @@ +startsConversation: boolean, +startsCluster: boolean, endsCluster: boolean, - +threadCreatedFromMessage: ?ThreadInfo, + +threadCreatedFromMessage: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +reactions: ReactionInfo, +hasBeenEdited: boolean, +isPinned: boolean, diff --git a/lib/shared/mention-utils.js b/lib/shared/mention-utils.js --- a/lib/shared/mention-utils.js +++ b/lib/shared/mention-utils.js @@ -4,7 +4,11 @@ import SentencePrefixSearchIndex from './sentence-prefix-search-index.js'; import { threadOtherMembers } from './thread-utils.js'; import { stringForUserExplicit } from './user-utils.js'; -import type { MinimallyEncodedResolvedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedResolvedThreadInfo, + MinimallyEncodedThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from '../types/thread-types-enum.js'; import type { ThreadInfo, @@ -26,7 +30,7 @@ type MentionTypeaheadUserSuggestionItem = { +type: 'user', - +userInfo: RelativeMemberInfo, + +userInfo: RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, }; type MentionTypeaheadChatSuggestionItem = { @@ -105,7 +109,9 @@ function getMentionTypeaheadUserSuggestions( userSearchIndex: SentencePrefixSearchIndex, - threadMembers: $ReadOnlyArray, + threadMembers: $ReadOnlyArray< + RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, viewerID: ?string, usernamePrefix: string, ): $ReadOnlyArray { @@ -161,9 +167,9 @@ } function getUserMentionsCandidates( - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, -): $ReadOnlyArray { + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +): $ReadOnlyArray { if (threadInfo.type !== threadTypes.SIDEBAR) { return threadInfo.members; } diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js --- a/lib/shared/message-utils.js +++ b/lib/shared/message-utils.js @@ -78,8 +78,8 @@ function robotextForMessageInfo( messageInfo: RobotextMessageInfo, - threadInfo: ?ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ): EntityText { const messageSpec = messageSpecs[messageInfo.type]; invariant( @@ -413,8 +413,8 @@ | RobotextMessageInfo | ReactionMessageInfo | EditMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, markdownRules: ParserRules, ): EntityText { const { messageTitle } = messageSpecs[messageInfo.type]; @@ -500,7 +500,7 @@ }; function useMessagePreview( originalMessageInfo: ?MessageInfo, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, markdownRules: ParserRules, ): ?MessagePreviewResult { let messageInfo; diff --git a/lib/shared/messages/message-spec.js b/lib/shared/messages/message-spec.js --- a/lib/shared/messages/message-spec.js +++ b/lib/shared/messages/message-spec.js @@ -12,6 +12,7 @@ RawRobotextMessageInfo, } from '../../types/message-types.js'; import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported.js'; +import type { MinimallyEncodedThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js'; import type { NotifTexts } from '../../types/notif-types.js'; import type { ThreadInfo } from '../../types/thread-types.js'; import type { RelativeUserInfo, UserInfo } from '../../types/user-types.js'; @@ -20,7 +21,7 @@ export type MessageTitleParam = { +messageInfo: Info, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +markdownRules: ParserRules, }; @@ -42,8 +43,8 @@ }; export type RobotextParams = { - +threadInfo: ?ThreadInfo, - +parentThreadInfo: ?ThreadInfo, + +threadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, + +parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, }; export type NotificationTextsParams = { @@ -65,8 +66,8 @@ export type CreationSideEffectsFunc = ( messageInfo: RawInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => Promise; export type MessageSpec = { diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js --- a/lib/shared/messages/text-message-spec.js +++ b/lib/shared/messages/text-message-spec.js @@ -25,6 +25,7 @@ type TextMessageInfo, rawTextMessageInfoValidator, } from '../../types/messages/text.js'; +import type { MinimallyEncodedThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js'; import type { NotifTexts } from '../../types/notif-types.js'; import { threadTypes } from '../../types/thread-types-enum.js'; import type { ThreadInfo } from '../../types/thread-types.js'; @@ -285,8 +286,8 @@ const callChangeThreadSettings = useChangeThreadSettings(); return async ( messageInfo: RawTextMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => { if (threadInfo.type !== threadTypes.SIDEBAR) { return; 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 @@ -407,7 +407,7 @@ +viewerID: string, +threadType: ThreadType, +members: $ReadOnlyArray, - +parentThreadInfo?: ?ThreadInfo, + +parentThreadInfo?: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +threadColor?: ?string, +name?: ?string, +sourceMessageID?: string, @@ -590,7 +590,7 @@ type SharedCreatePendingSidebarInput = { +sourceMessageInfo: ComposableMessageInfo | RobotextMessageInfo, - +parentThreadInfo: ThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +loggedInUserInfo: LoggedInUserInfo, }; @@ -1319,9 +1319,10 @@ }; type ExistingThreadInfoFinder = ( params: ExistingThreadInfoFinderParams, -) => ?ThreadInfo; +) => ?ThreadInfo | ?MinimallyEncodedThreadInfo; +// TODO (atul): Parameterize function once `createPendingThread` is updated. function useExistingThreadInfoFinder( - baseThreadInfo: ?ThreadInfo, + baseThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ): ExistingThreadInfoFinder { const threadInfos = useSelector(threadInfoSelector); const loggedInUserInfo = useLoggedInUserInfo(); @@ -1331,7 +1332,9 @@ pendingToRealizedThreadIDsSelector(state.threadStore.threadInfos), ); return React.useCallback( - (params: ExistingThreadInfoFinderParams): ?ThreadInfo => { + ( + params: ExistingThreadInfoFinderParams, + ): ?ThreadInfo | ?MinimallyEncodedThreadInfo => { if (!baseThreadInfo) { return null; } @@ -1379,10 +1382,22 @@ members: [loggedInUserInfo, ...userInfoInputArray], }) : baseThreadInfo; - return { - ...updatedThread, - currentUser: getCurrentUser(updatedThread, viewerID, userInfos), - }; + + if (updatedThread.minimallyEncoded) { + return { + ...updatedThread, + currentUser: getMinimallyEncodedCurrentUser( + updatedThread, + viewerID, + userInfos, + ), + }; + } else { + return { + ...updatedThread, + currentUser: getCurrentUser(updatedThread, viewerID, userInfos), + }; + } }, [ baseThreadInfo, @@ -1632,7 +1647,7 @@ function removeMemberFromThread( threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, - memberInfo: RelativeMemberInfo, + memberInfo: RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, dispatchActionPromise: DispatchActionPromise, removeUserFromThreadServerCall: ( input: RemoveUsersFromThreadInput, @@ -1718,11 +1733,11 @@ } function patchThreadInfoToIncludeMentionedMembersOfParent( - threadInfo: ThreadInfo, - parentThreadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, messageText: string, viewerID: string, -): ThreadInfo { +): ThreadInfo | MinimallyEncodedThreadInfo { const members: UserIDAndUsername[] = threadInfo.members .map(({ id, username }) => (username ? { id, username } : null)) .filter(Boolean); diff --git a/lib/utils/drawer-utils.react.js b/lib/utils/drawer-utils.react.js --- a/lib/utils/drawer-utils.react.js +++ b/lib/utils/drawer-utils.react.js @@ -4,6 +4,7 @@ import { threadInFilterList, threadIsChannel } from '../shared/thread-utils.js'; import type { MinimallyEncodedRawThreadInfo, + MinimallyEncodedResolvedThreadInfo, MinimallyEncodedThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { communitySubthreads } from '../types/thread-types-enum.js'; @@ -14,15 +15,19 @@ } from '../types/thread-types.js'; export type CommunityDrawerItemData = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +itemChildren: $ReadOnlyArray>, +hasSubchannelsButton: boolean, +labelStyle: T, }; function createRecursiveDrawerItemsData( - childThreadInfosMap: { +[id: string]: $ReadOnlyArray }, - communities: $ReadOnlyArray, + childThreadInfosMap: { + +[id: string]: $ReadOnlyArray, + }, + communities: $ReadOnlyArray< + ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + >, labelStyles: $ReadOnlyArray, maxDepth: number, ): $ReadOnlyArray> { @@ -57,12 +62,10 @@ return result; } -function threadHasSubchannels( - threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +function threadHasSubchannels( + threadInfo: T, childThreadInfosMap: { - +[id: string]: - | $ReadOnlyArray - | $ReadOnlyArray, + +[id: string]: $ReadOnlyArray, }, ): boolean { if (!childThreadInfosMap[threadInfo.id]?.length) { @@ -73,9 +76,9 @@ ); } -function appendSuffix( - chats: $ReadOnlyArray, -): ResolvedThreadInfo[] { +function appendSuffix< + T: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +>(chats: $ReadOnlyArray): T[] { const result = []; const names = new Map(); @@ -86,7 +89,12 @@ if (numberOfOccurrences) { name = `${name} (${numberOfOccurrences.toString()})`; } - result.push({ ...chat, uiName: name }); + // Branching to appease `flow`. + if (chat.minimallyEncoded) { + result.push({ ...chat, uiName: name }); + } else { + result.push({ ...chat, uiName: name }); + } } return result; } diff --git a/lib/utils/entity-helpers.js b/lib/utils/entity-helpers.js --- a/lib/utils/entity-helpers.js +++ b/lib/utils/entity-helpers.js @@ -9,13 +9,17 @@ entityTextToRawString, } from './entity-text.js'; import type { UseENSNamesOptions } from '../hooks/ens-cache.js'; +import type { + MinimallyEncodedResolvedThreadInfo, + MinimallyEncodedThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo, ResolvedThreadInfo } from '../types/thread-types.js'; import { values } from '../utils/objects.js'; function useResolvedThreadInfos( - threadInfos: $ReadOnlyArray, + threadInfos: $ReadOnlyArray, options?: ?UseENSNamesOptions, -): $ReadOnlyArray { +): $ReadOnlyArray { const entityText = React.useMemo( () => threadInfos.map(threadInfo => threadInfo.uiName), [threadInfos], @@ -34,10 +38,18 @@ return (threadInfo: any); } const resolvedThreadEntity = withENSNames[i]; - return { - ...threadInfo, - uiName: entityTextToRawString([resolvedThreadEntity]), - }; + // Branching to appease `flow`. + if (threadInfo.minimallyEncoded) { + return { + ...threadInfo, + uiName: entityTextToRawString([resolvedThreadEntity]), + }; + } else { + return { + ...threadInfo, + uiName: entityTextToRawString([resolvedThreadEntity]), + }; + } }), [threadInfos, withENSNames], ); @@ -99,15 +111,17 @@ }, [resolvedThreadInfosArray]); } -function useResolvedThreadInfo(threadInfo: ThreadInfo): ResolvedThreadInfo { +function useResolvedThreadInfo( + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +): ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo { const resolutionInput = React.useMemo(() => [threadInfo], [threadInfo]); const [resolvedThreadInfo] = useResolvedThreadInfos(resolutionInput); return resolvedThreadInfo; } function useResolvedOptionalThreadInfo( - threadInfo: ?ThreadInfo, -): ?ResolvedThreadInfo { + threadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +): ?ResolvedThreadInfo | ?MinimallyEncodedResolvedThreadInfo { const resolutionInput = React.useMemo( () => (threadInfo ? [threadInfo] : []), [threadInfo], diff --git a/native/calendar/entry.react.js b/native/calendar/entry.react.js --- a/native/calendar/entry.react.js +++ b/native/calendar/entry.react.js @@ -44,6 +44,7 @@ CalendarQuery, } from 'lib/types/entry-types.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; +import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { @@ -120,7 +121,7 @@ }; type Props = { ...SharedProps, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, // Redux state +calendarQuery: () => CalendarQuery, +online: boolean, diff --git a/native/chat/chat-context-provider.react.js b/native/chat/chat-context-provider.react.js --- a/native/chat/chat-context-provider.react.js +++ b/native/chat/chat-context-provider.react.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { ChatContext } from './chat-context.js'; @@ -16,7 +17,7 @@ export type MeasurementTask = { +messages: $ReadOnlyArray, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +onMessagesMeasured: ( messagesWithHeight: $ReadOnlyArray, measuredHeights: $ReadOnlyMap, @@ -37,7 +38,7 @@ const measureMessages = React.useCallback( ( messages: ?$ReadOnlyArray, - threadInfo: ?ThreadInfo, + threadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, onMessagesMeasured: ($ReadOnlyArray) => mixed, measurerID: number, ) => { @@ -93,7 +94,7 @@ return { measure: ( messages: ?$ReadOnlyArray, - threadInfo: ?ThreadInfo, + threadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, onMessagesMeasured: ( $ReadOnlyArray, ) => mixed, diff --git a/native/chat/chat-context.js b/native/chat/chat-context.js --- a/native/chat/chat-context.js +++ b/native/chat/chat-context.js @@ -4,6 +4,7 @@ import * as React from 'react'; import type { SetState } from 'lib/types/hook-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import type { NativeChatMessageItem } from './message-data.react.js'; @@ -11,7 +12,7 @@ export type MessagesMeasurer = ( ?$ReadOnlyArray, - ?ThreadInfo, + ?ThreadInfo | ?MinimallyEncodedThreadInfo, ($ReadOnlyArray) => mixed, ) => void; diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -71,6 +71,10 @@ SendEditMessageResponse, MessageInfo, } from 'lib/types/message-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import type { @@ -154,7 +158,7 @@ }; type BaseProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type Props = { ...BaseProps, @@ -176,7 +180,9 @@ +joinThread: (request: ClientThreadJoinRequest) => Promise, +inputState: ?InputState, +userSearchIndex: SentencePrefixSearchIndex, - +userMentionsCandidates: $ReadOnlyArray, + +userMentionsCandidates: $ReadOnlyArray< + RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, +chatMentionSearchIndex: SentencePrefixSearchIndex, +chatMentionCandidates: ChatMentionCandidates, +parentThreadInfo: ?ThreadInfo, diff --git a/native/chat/compose-subchannel.react.js b/native/chat/compose-subchannel.react.js --- a/native/chat/compose-subchannel.react.js +++ b/native/chat/compose-subchannel.react.js @@ -19,6 +19,7 @@ } from 'lib/selectors/user-selectors.js'; import { getPotentialMemberItems } from 'lib/shared/search-utils.js'; import { threadInFilterList, userIsMember } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadType, threadTypes } from 'lib/types/thread-types-enum.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { type AccountUserInfo } from 'lib/types/user-types.js'; @@ -49,7 +50,7 @@ export type ComposeSubchannelParams = { +threadType: ThreadType, - +parentThreadInfo: ThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type Props = { diff --git a/native/chat/inline-engagement.react.js b/native/chat/inline-engagement.react.js --- a/native/chat/inline-engagement.react.js +++ b/native/chat/inline-engagement.react.js @@ -129,8 +129,8 @@ type Props = { +messageInfo: MessageInfo, - +threadInfo: ThreadInfo, - +sidebarThreadInfo: ?ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + +sidebarThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +reactions: ReactionInfo, +disabled?: boolean, +positioning?: 'left' | 'right' | 'center', diff --git a/native/chat/message-list-container.react.js b/native/chat/message-list-container.react.js --- a/native/chat/message-list-container.react.js +++ b/native/chat/message-list-container.react.js @@ -20,6 +20,7 @@ useExistingThreadInfoFinder, pendingThreadType, } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import type { AccountUserInfo, UserListItem } from 'lib/types/user-types.js'; @@ -62,8 +63,8 @@ +updateTagInput: (items: $ReadOnlyArray) => void, +resolveToUser: (user: AccountUserInfo) => void, +userSearchResults: $ReadOnlyArray, - +threadInfo: ThreadInfo, - +genesisThreadInfo: ?ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + +genesisThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +messageListData: ?$ReadOnlyArray, +colors: Colors, +styles: typeof unboundStyles, diff --git a/native/chat/message-list-header-title.react.js b/native/chat/message-list-header-title.react.js --- a/native/chat/message-list-header-title.react.js +++ b/native/chat/message-list-header-title.react.js @@ -7,6 +7,7 @@ import * as React from 'react'; import { View } from 'react-native'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; import { firstLine } from 'lib/utils/string-utils.js'; @@ -18,7 +19,7 @@ import { useStyles } from '../themes/colors.js'; type BaseProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +navigate: $PropertyType, 'navigate'>, +isSearchEmpty: boolean, +areSettingsEnabled: boolean, diff --git a/native/chat/message-list-types.js b/native/chat/message-list-types.js --- a/native/chat/message-list-types.js +++ b/native/chat/message-list-types.js @@ -19,7 +19,7 @@ } from '../navigation/route-names.js'; export type MessageListParams = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +pendingPersonalThreadUserInfo?: UserInfo, +searching?: boolean, +removeEditMode?: ?RemoveEditMode, @@ -54,7 +54,7 @@ type Props = { +children: React.Node, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function MessageListContextProvider(props: Props): React.Node { const context = useMessageListContext(props.threadInfo); diff --git a/native/chat/message-result.react.js b/native/chat/message-result.react.js --- a/native/chat/message-result.react.js +++ b/native/chat/message-result.react.js @@ -4,6 +4,7 @@ import { Text, View } from 'react-native'; import { ScrollView } from 'react-native-gesture-handler'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { longAbsoluteDate } from 'lib/utils/date-utils.js'; @@ -19,7 +20,7 @@ type MessageResultProps = { +item: ChatMessageInfoItemWithHeight, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +navigation: | AppNavigationProp<'TogglePinModal'> | ChatNavigationProp<'MessageResultsScreen'> diff --git a/native/chat/message-results-screen.react.js b/native/chat/message-results-screen.react.js --- a/native/chat/message-results-screen.react.js +++ b/native/chat/message-results-screen.react.js @@ -11,6 +11,7 @@ createMessageInfo, isInvalidPinSourceForThread, } from 'lib/shared/message-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useHeightMeasurer } from './chat-context.js'; @@ -22,7 +23,7 @@ import type { ChatMessageItemWithHeight } from '../types/chat-types.js'; export type MessageResultsScreenParams = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type MessageResultsScreenProps = { diff --git a/native/chat/parent-thread-header.react.js b/native/chat/parent-thread-header.react.js --- a/native/chat/parent-thread-header.react.js +++ b/native/chat/parent-thread-header.react.js @@ -4,6 +4,7 @@ import { View, Text } from 'react-native'; import { ScrollView } from 'react-native-gesture-handler'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadType } from 'lib/types/thread-types-enum.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; @@ -14,7 +15,7 @@ import { useColors, useStyles } from '../themes/colors.js'; type Props = { - +parentThreadInfo: ThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +childThreadType: ThreadType, }; function ParentThreadHeader(props: Props): React.Node { diff --git a/native/chat/settings/compose-subchannel-modal.react.js b/native/chat/settings/compose-subchannel-modal.react.js --- a/native/chat/settings/compose-subchannel-modal.react.js +++ b/native/chat/settings/compose-subchannel-modal.react.js @@ -5,6 +5,7 @@ import { Text } from 'react-native'; import { threadTypeDescriptions } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; @@ -18,7 +19,7 @@ export type ComposeSubchannelModalParams = { +presentedFrom: string, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type BaseProps = { diff --git a/native/chat/settings/thread-settings-child-thread.react.js b/native/chat/settings/thread-settings-child-thread.react.js --- a/native/chat/settings/thread-settings-child-thread.react.js +++ b/native/chat/settings/thread-settings-child-thread.react.js @@ -3,6 +3,7 @@ import * as React from 'react'; import { View, Platform } from 'react-native'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import ThreadAvatar from '../../avatars/thread-avatar.react.js'; @@ -13,7 +14,7 @@ import { useNavigateToThread } from '../message-list-types.js'; type Props = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +firstListItem: boolean, +lastListItem: boolean, }; diff --git a/native/chat/settings/thread-settings-member-tooltip-modal.react.js b/native/chat/settings/thread-settings-member-tooltip-modal.react.js --- a/native/chat/settings/thread-settings-member-tooltip-modal.react.js +++ b/native/chat/settings/thread-settings-member-tooltip-modal.react.js @@ -5,6 +5,10 @@ import { useRemoveUsersFromThread } from 'lib/actions/thread-actions.js'; import { removeMemberFromThread } from 'lib/shared/thread-utils.js'; import { stringForUser } from 'lib/shared/user-utils.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo, RelativeMemberInfo } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/action-utils.js'; @@ -21,8 +25,8 @@ import Alert from '../../utils/alert.js'; export type ThreadSettingsMemberTooltipModalParams = TooltipParams<{ - +memberInfo: RelativeMemberInfo, - +threadInfo: ThreadInfo, + +memberInfo: RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }>; function useOnRemoveUser( diff --git a/native/chat/settings/thread-settings-member.react.js b/native/chat/settings/thread-settings-member.react.js --- a/native/chat/settings/thread-settings-member.react.js +++ b/native/chat/settings/thread-settings-member.react.js @@ -19,6 +19,10 @@ import { getAvailableThreadMemberActions } from 'lib/shared/thread-utils.js'; import { stringForUser } from 'lib/shared/user-utils.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo, type RelativeMemberInfo, @@ -44,8 +48,8 @@ import { useNavigateToUserProfileBottomSheet } from '../../user-profile/user-profile-utils.js'; type BaseProps = { - +memberInfo: RelativeMemberInfo, - +threadInfo: ThreadInfo, + +memberInfo: RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +canEdit: boolean, +navigate: ThreadSettingsNavigate, +firstListItem: boolean, diff --git a/native/chat/settings/thread-settings-parent.react.js b/native/chat/settings/thread-settings-parent.react.js --- a/native/chat/settings/thread-settings-parent.react.js +++ b/native/chat/settings/thread-settings-parent.react.js @@ -13,7 +13,7 @@ import { useNavigateToThread } from '../message-list-types.js'; type ParentButtonProps = { - +parentThreadInfo: ThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function ParentButton(props: ParentButtonProps): React.Node { const styles = useStyles(unboundStyles); @@ -36,7 +36,7 @@ type ThreadSettingsParentProps = { +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, - +parentThreadInfo: ?ThreadInfo, + +parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, }; function ThreadSettingsParent(props: ThreadSettingsParentProps): React.Node { const { threadInfo, parentThreadInfo } = props; diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js --- a/native/chat/settings/thread-settings.react.js +++ b/native/chat/settings/thread-settings.react.js @@ -29,6 +29,7 @@ } from 'lib/shared/thread-utils.js'; import threadWatcher from 'lib/shared/thread-watcher.js'; import type { + MinimallyEncodedRelativeMemberInfo, MinimallyEncodedResolvedThreadInfo, MinimallyEncodedThreadInfo, } from 'lib/types/minimally-encoded-thread-permissions-types.js'; @@ -104,7 +105,7 @@ const itemPageLength = 5; export type ThreadSettingsParams = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; export type ThreadSettingsNavigate = $PropertyType< @@ -164,8 +165,10 @@ | { +itemType: 'parent', +key: string, - +threadInfo: ResolvedThreadInfo, - +parentThreadInfo: ?ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + +parentThreadInfo: + | ?ResolvedThreadInfo + | ?MinimallyEncodedResolvedThreadInfo, } | { +itemType: 'visibility', @@ -190,7 +193,7 @@ | { +itemType: 'childThread', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +firstListItem: boolean, +lastListItem: boolean, } @@ -201,8 +204,8 @@ | { +itemType: 'member', +key: string, - +memberInfo: RelativeMemberInfo, - +threadInfo: ResolvedThreadInfo, + +memberInfo: RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +canEdit: boolean, +navigate: ThreadSettingsNavigate, +firstListItem: boolean, @@ -246,8 +249,8 @@ // Redux state +userInfos: UserInfos, +viewerID: ?string, - +threadInfo: ResolvedThreadInfo, - +parentThreadInfo: ?ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + +parentThreadInfo: ?ResolvedThreadInfo | ?MinimallyEncodedResolvedThreadInfo, +childThreadInfos: ?$ReadOnlyArray, +somethingIsSaving: boolean, +styles: typeof unboundStyles, @@ -325,8 +328,10 @@ (propsAndState: PropsAndState) => propsAndState.navigation.navigate, (propsAndState: PropsAndState) => propsAndState.route.key, ( - threadInfo: ResolvedThreadInfo, - parentThreadInfo: ?ResolvedThreadInfo, + threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + parentThreadInfo: + | ?ResolvedThreadInfo + | ?MinimallyEncodedResolvedThreadInfo, nameEditValue: ?string, colorEditValue: string, descriptionEditValue: ?string, @@ -478,9 +483,11 @@ (propsAndState: PropsAndState) => propsAndState.childThreadInfos, (propsAndState: PropsAndState) => propsAndState.numSubchannelsShowing, ( - threadInfo: ResolvedThreadInfo, + threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, navigate: ThreadSettingsNavigate, - childThreads: ?$ReadOnlyArray, + childThreads: ?$ReadOnlyArray< + ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + >, numSubchannelsShowing: number, ) => { const listData: ChatSettingsItem[] = []; @@ -544,7 +551,9 @@ (propsAndState: PropsAndState) => propsAndState.numSidebarsShowing, ( navigate: ThreadSettingsNavigate, - childThreads: ?$ReadOnlyArray, + childThreads: ?$ReadOnlyArray< + ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + >, numSidebarsShowing: number, ) => { const listData: ChatSettingsItem[] = []; @@ -602,7 +611,7 @@ (propsAndState: PropsAndState) => propsAndState.numMembersShowing, (propsAndState: PropsAndState) => propsAndState.verticalBounds, ( - threadInfo: ResolvedThreadInfo, + threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, canStartEditing: boolean, navigate: ThreadSettingsNavigate, routeKey: string, @@ -713,8 +722,10 @@ (propsAndState: PropsAndState) => propsAndState.userInfos, (propsAndState: PropsAndState) => propsAndState.viewerID, ( - threadInfo: ResolvedThreadInfo, - parentThreadInfo: ?ResolvedThreadInfo, + threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, + parentThreadInfo: + | ?ResolvedThreadInfo + | ?MinimallyEncodedResolvedThreadInfo, navigate: ThreadSettingsNavigate, styles: typeof unboundStyles, userInfos: UserInfos, @@ -1115,7 +1126,9 @@ const threadMembersChangeIsSaving = ( state: AppState, - threadMembers: $ReadOnlyArray, + threadMembers: $ReadOnlyArray< + RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ) => { for (const threadMember of threadMembers) { const removeUserLoadingStatus = createLoadingStatusSelector( @@ -1161,7 +1174,7 @@ setParams({ threadInfo: reduxThreadInfo }); } }, [reduxThreadInfo, setParams]); - const threadInfo: ThreadInfo = + const threadInfo: ThreadInfo | MinimallyEncodedThreadInfo = reduxThreadInfo ?? props.route.params.threadInfo; const resolvedThreadInfo = useResolvedThreadInfo(threadInfo); diff --git a/native/chat/sidebar-navigation.js b/native/chat/sidebar-navigation.js --- a/native/chat/sidebar-navigation.js +++ b/native/chat/sidebar-navigation.js @@ -10,6 +10,7 @@ createPendingSidebar, createUnresolvedPendingSidebar, } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo, ChatMentionCandidates, @@ -29,7 +30,7 @@ }; function getUnresolvedSidebarThreadInfo( input: GetUnresolvedSidebarThreadInfoInput, -): ?ThreadInfo { +): ?ThreadInfo | ?MinimallyEncodedThreadInfo { const { sourceMessage, loggedInUserInfo, chatMentionCandidates } = input; const threadCreatedFromMessage = sourceMessage.threadCreatedFromMessage; if (threadCreatedFromMessage) { @@ -56,7 +57,7 @@ }; async function getSidebarThreadInfo( input: GetSidebarThreadInfoInput, -): Promise { +): Promise { const { sourceMessage, loggedInUserInfo, diff --git a/native/chat/thread-settings-button.react.js b/native/chat/thread-settings-button.react.js --- a/native/chat/thread-settings-button.react.js +++ b/native/chat/thread-settings-button.react.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import type { ChatNavigationProp } from './chat.react.js'; @@ -11,7 +12,7 @@ import { useStyles } from '../themes/colors.js'; type BaseProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +navigate: $PropertyType, 'navigate'>, }; type Props = { diff --git a/native/chat/thread-settings-header-title.react.js b/native/chat/thread-settings-header-title.react.js --- a/native/chat/thread-settings-header-title.react.js +++ b/native/chat/thread-settings-header-title.react.js @@ -6,12 +6,13 @@ } from '@react-navigation/elements'; import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; import { firstLine } from 'lib/utils/string-utils.js'; type Props = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ...HeaderTitleInputProps, }; function ThreadSettingsHeaderTitle(props: Props): React.Node { diff --git a/native/chat/utils.js b/native/chat/utils.js --- a/native/chat/utils.js +++ b/native/chat/utils.js @@ -9,6 +9,7 @@ import { colorIsDark } from 'lib/shared/color-utils.js'; import { messageKey } from 'lib/shared/message-utils.js'; import { viewerIsMember } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { clusterEndHeight } from './chat-constants.js'; @@ -102,7 +103,7 @@ messageListVerticalBounds: VerticalBounds, currentInputBarHeight: number, targetInputBarHeight: number, - sidebarThreadInfo: ?ThreadInfo, + sidebarThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ): { +position: number, +color: string, diff --git a/native/components/community-pill.react.js b/native/components/community-pill.react.js --- a/native/components/community-pill.react.js +++ b/native/components/community-pill.react.js @@ -4,6 +4,7 @@ import { View, StyleSheet } from 'react-native'; import { useKeyserverAdmin } from 'lib/shared/user-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import CommIcon from './comm-icon.react.js'; @@ -14,7 +15,7 @@ const threadPillRoundCorners = { left: false, right: true }; type Props = { - +community: ThreadInfo, + +community: ThreadInfo | MinimallyEncodedThreadInfo, }; function CommunityPill(props: Props): React.Node { const { community } = props; diff --git a/native/components/thread-pill.react.js b/native/components/thread-pill.react.js --- a/native/components/thread-pill.react.js +++ b/native/components/thread-pill.react.js @@ -2,13 +2,14 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; import Pill from './pill.react.js'; type Props = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +roundCorners?: { +left: boolean, +right: boolean }, +fontSize?: number, }; diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -71,6 +71,7 @@ import type { RawMediaMessageInfo } from 'lib/types/messages/media.js'; import { getMediaMessageServerDBContentsFromMedia } from 'lib/types/messages/media.js'; import type { RawTextMessageInfo } from 'lib/types/messages/text.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { type ClientMediaMissionReportCreationRequest, @@ -165,7 +166,10 @@ > = []; scrollToMessageCallbacks: Array<(messageID: string) => void> = []; pendingThreadCreations = new Map>(); - pendingThreadUpdateHandlers = new Map mixed>(); + pendingThreadUpdateHandlers = new Map< + string, + (ThreadInfo | MinimallyEncodedThreadInfo) => mixed, + >(); // TODO: flip the switch // Note that this enables Blob service for encrypted media only useBlobServiceUploads = false; @@ -435,8 +439,8 @@ sendTextMessage = async ( messageInfo: RawTextMessageInfo, - inputThreadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + inputThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => { this.sendCallbacks.forEach(callback => callback()); @@ -508,10 +512,18 @@ threadID: newThreadID, time: Date.now(), }; - const newThreadInfo = { - ...threadInfo, - id: newThreadID, - }; + + // Branching to appease `flow`. + const newThreadInfo = threadInfo.minimallyEncoded + ? { + ...threadInfo, + id: newThreadID, + } + : { + ...threadInfo, + id: newThreadID, + }; + this.props.dispatchActionPromise( sendTextMessageActionTypes, this.sendTextMessageAction( @@ -524,7 +536,9 @@ ); }; - startThreadCreation(threadInfo: ThreadInfo): Promise { + startThreadCreation( + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + ): Promise { if (!threadIsPending(threadInfo.id)) { return Promise.resolve(threadInfo.id); } @@ -546,8 +560,8 @@ async sendTextMessageAction( messageInfo: RawTextMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ): Promise { try { await this.props.textMessageCreationSideEffectsFunc( @@ -584,13 +598,15 @@ } } - shouldEncryptMedia(threadInfo: ThreadInfo): boolean { + shouldEncryptMedia( + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + ): boolean { return threadInfoInsideCommunity(threadInfo, commStaffCommunity.id); } sendMultimediaMessage = async ( selections: $ReadOnlyArray, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ) => { this.sendCallbacks.forEach(callback => callback()); const localMessageID = this.props.nextLocalID; @@ -691,7 +707,7 @@ async uploadFiles( localMessageID: string, uploadFileInputs: $ReadOnlyArray, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ) { const results = await Promise.all( uploadFileInputs.map(uploadFileInput => @@ -707,7 +723,7 @@ async uploadFile( localMessageID: string, uploadFileInput: UploadFileInput, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): Promise { const { ids, selection } = uploadFileInput; const { localMediaID } = ids; @@ -1314,8 +1330,8 @@ retryTextMessage = async ( rawMessageInfo: RawTextMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => { await this.sendTextMessage( { @@ -1330,7 +1346,7 @@ retryMultimediaMessage = async ( rawMessageInfo: RawMultimediaMessageInfo, localMessageID: string, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ) => { const pendingUploads = this.state.pendingUploads[localMessageID] ?? {}; @@ -1544,8 +1560,8 @@ retryMessage = async ( localMessageID: string, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => { this.sendCallbacks.forEach(callback => callback()); @@ -1640,7 +1656,9 @@ setPendingThreadUpdateHandler = ( threadID: string, - pendingThreadUpdateHandler: ?(ThreadInfo) => mixed, + pendingThreadUpdateHandler: ?( + ThreadInfo | MinimallyEncodedThreadInfo, + ) => mixed, ) => { if (!pendingThreadUpdateHandler) { this.pendingThreadUpdateHandlers.delete(threadID); diff --git a/native/input/input-state.js b/native/input/input-state.js --- a/native/input/input-state.js +++ b/native/input/input-state.js @@ -4,6 +4,7 @@ import type { NativeMediaSelection } from 'lib/types/media-types.js'; import type { RawTextMessageInfo } from 'lib/types/messages/text.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; export type MultimediaProcessingStep = 'transcoding' | 'uploading'; @@ -31,12 +32,12 @@ +pendingUploads: PendingMultimediaUploads, +sendTextMessage: ( messageInfo: RawTextMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => Promise, +sendMultimediaMessage: ( selections: $ReadOnlyArray, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ) => Promise, +editInputMessage: (params: EditInputBarMessageParameters) => void, +addEditInputMessageListener: ( @@ -48,8 +49,8 @@ +messageHasUploadFailure: (localMessageID: string) => boolean, +retryMessage: ( localMessageID: string, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => Promise, +registerSendCallback: (() => void) => void, +unregisterSendCallback: (() => void) => void, @@ -57,7 +58,9 @@ +reportURIDisplayed: (uri: string, loaded: boolean) => void, +setPendingThreadUpdateHandler: ( threadID: string, - pendingThreadUpdateHandler: ?(ThreadInfo) => mixed, + pendingThreadUpdateHandler: ?( + ThreadInfo | MinimallyEncodedThreadInfo, + ) => mixed, ) => void, +scrollToMessage: (messageKey: string) => void, +addScrollToMessageListener: ((messageKey: string) => void) => void, diff --git a/native/keyboard/keyboard-state-container.react.js b/native/keyboard/keyboard-state-container.react.js --- a/native/keyboard/keyboard-state-container.react.js +++ b/native/keyboard/keyboard-state-container.react.js @@ -4,6 +4,7 @@ import { Platform } from 'react-native'; import { KeyboardUtils } from 'react-native-keyboard-input'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import sleep from 'lib/utils/sleep.js'; @@ -23,7 +24,7 @@ type State = { +systemKeyboardShowing: boolean, +mediaGalleryOpen: boolean, - +mediaGalleryThread: ?ThreadInfo, + +mediaGalleryThread: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +renderKeyboardInputHost: boolean, }; class KeyboardStateContainer extends React.PureComponent { @@ -93,12 +94,13 @@ return systemKeyboardShowing || mediaGalleryOpen; } - showMediaGallery: (thread: ThreadInfo) => void = (thread: ThreadInfo) => { - this.setState({ - mediaGalleryOpen: true, - mediaGalleryThread: thread, - }); - }; + showMediaGallery: (thread: ThreadInfo | MinimallyEncodedThreadInfo) => void = + (thread: ThreadInfo | MinimallyEncodedThreadInfo) => { + this.setState({ + mediaGalleryOpen: true, + mediaGalleryThread: thread, + }); + }; hideMediaGallery: () => void = () => { this.setState({ @@ -108,7 +110,7 @@ }); }; - getMediaGalleryThread: () => ?ThreadInfo = () => + getMediaGalleryThread: () => ?ThreadInfo | ?MinimallyEncodedThreadInfo = () => this.state.mediaGalleryThread; render(): React.Node { diff --git a/native/keyboard/keyboard-state.js b/native/keyboard/keyboard-state.js --- a/native/keyboard/keyboard-state.js +++ b/native/keyboard/keyboard-state.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; export type KeyboardState = { @@ -10,9 +11,9 @@ +dismissKeyboardIfShowing: () => boolean, +systemKeyboardShowing: boolean, +mediaGalleryOpen: boolean, - +showMediaGallery: (thread: ThreadInfo) => void, + +showMediaGallery: (thread: ThreadInfo | MinimallyEncodedThreadInfo) => void, +hideMediaGallery: () => void, - +getMediaGalleryThread: () => ?ThreadInfo, + +getMediaGalleryThread: () => ?ThreadInfo | ?MinimallyEncodedThreadInfo, }; const KeyboardContext: React.Context = diff --git a/native/media/chat-camera-modal.react.js b/native/media/chat-camera-modal.react.js --- a/native/media/chat-camera-modal.react.js +++ b/native/media/chat-camera-modal.react.js @@ -4,6 +4,7 @@ import * as React from 'react'; import type { PhotoCapture } from 'lib/types/media-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import CameraModal from './camera-modal.react.js'; @@ -13,7 +14,7 @@ export type ChatCameraModalParams = { +presentedFrom: string, - +thread: ThreadInfo, + +thread: ThreadInfo | MinimallyEncodedThreadInfo, }; type Props = { diff --git a/native/search/message-search.react.js b/native/search/message-search.react.js --- a/native/search/message-search.react.js +++ b/native/search/message-search.react.js @@ -12,6 +12,7 @@ filterChatMessageInfosForSearch, } from 'lib/shared/search-utils.js'; import type { RawMessageInfo } from 'lib/types/message-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import SearchFooter from './search-footer.react.js'; @@ -27,7 +28,7 @@ import type { ChatMessageItemWithHeight } from '../types/chat-types.js'; export type MessageSearchParams = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; export type MessageSearchProps = { diff --git a/native/search/search-messages-button.react.js b/native/search/search-messages-button.react.js --- a/native/search/search-messages-button.react.js +++ b/native/search/search-messages-button.react.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import type { ChatNavigationProp } from '../chat/chat.react.js'; @@ -11,7 +12,7 @@ import { useStyles } from '../themes/colors.js'; type Props = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +navigate: $PropertyType, 'navigate'>, }; diff --git a/native/types/chat-types.js b/native/types/chat-types.js --- a/native/types/chat-types.js +++ b/native/types/chat-types.js @@ -7,6 +7,7 @@ RobotextMessageInfo, } from 'lib/types/message-types.js'; import type { TextMessageInfo } from 'lib/types/messages/text.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import type { EntityText } from 'lib/utils/entity-text.js'; @@ -16,12 +17,12 @@ +itemType: 'message', +messageShapeType: 'robotext', +messageInfo: RobotextMessageInfo, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +startsConversation: boolean, +startsCluster: boolean, +endsCluster: boolean, +robotext: EntityText, - +threadCreatedFromMessage: ?ThreadInfo, + +threadCreatedFromMessage: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +contentHeight: number, +reactions: ReactionInfo, }; @@ -31,12 +32,12 @@ +messageShapeType: 'text', +messageInfo: TextMessageInfo, +localMessageInfo: ?LocalMessageInfo, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +startsConversation: boolean, +startsCluster: boolean, +endsCluster: boolean, +contentHeight: number, - +threadCreatedFromMessage: ?ThreadInfo, + +threadCreatedFromMessage: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +reactions: ReactionInfo, +hasBeenEdited: ?boolean, +isPinned: ?boolean, @@ -56,11 +57,11 @@ +messageShapeType: 'multimedia', +messageInfo: MultimediaMessageInfo, +localMessageInfo: ?LocalMessageInfo, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +startsConversation: boolean, +startsCluster: boolean, +endsCluster: boolean, - +threadCreatedFromMessage: ?ThreadInfo, + +threadCreatedFromMessage: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +pendingUploads: ?MessagePendingUploads, +reactions: ReactionInfo, +hasBeenEdited: ?boolean, diff --git a/native/utils/drawer-utils.react.js b/native/utils/drawer-utils.react.js --- a/native/utils/drawer-utils.react.js +++ b/native/utils/drawer-utils.react.js @@ -1,5 +1,6 @@ // @flow +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypeIsCommunityRoot } from 'lib/types/thread-types-enum.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import type { CommunityDrawerItemData } from 'lib/utils/drawer-utils.react.js'; @@ -7,7 +8,7 @@ import type { TextStyle } from '../types/styles.js'; export type CommunityDrawerItemDataFlattened = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +hasSubchannelsButton: boolean, +labelStyle: TextStyle, +hasChildren: boolean, diff --git a/web/chat/chat-input-bar.react.js b/web/chat/chat-input-bar.react.js --- a/web/chat/chat-input-bar.react.js +++ b/web/chat/chat-input-bar.react.js @@ -36,6 +36,7 @@ import type { CalendarQuery } from 'lib/types/entry-types.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { type ThreadInfo, @@ -67,7 +68,7 @@ } from '../utils/typeahead-utils.js'; type BaseProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +inputState: InputState, }; type Props = { diff --git a/web/chat/chat-message-list.react.js b/web/chat/chat-message-list.react.js --- a/web/chat/chat-message-list.react.js +++ b/web/chat/chat-message-list.react.js @@ -26,6 +26,7 @@ import { messageKey } from 'lib/shared/message-utils.js'; import { threadIsPending } from 'lib/shared/thread-utils.js'; import type { FetchMessageInfosPayload } from 'lib/types/message-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { @@ -55,7 +56,7 @@ const editBoxTopMargin = 10; type BaseProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type Props = { diff --git a/web/chat/composed-message.react.js b/web/chat/composed-message.react.js --- a/web/chat/composed-message.react.js +++ b/web/chat/composed-message.react.js @@ -12,6 +12,7 @@ import { type ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { getMessageLabel } from 'lib/shared/edit-messages-utils.js'; import { assertComposableMessageType } from 'lib/types/message-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { getComposedMessageID } from './chat-constants.js'; @@ -50,7 +51,7 @@ type BaseProps = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +shouldDisplayPinIndicator: boolean, +sendFailed: boolean, +children: React.Node, diff --git a/web/chat/edit-message-provider.js b/web/chat/edit-message-provider.js --- a/web/chat/edit-message-provider.js +++ b/web/chat/edit-message-provider.js @@ -5,6 +5,7 @@ import ModalOverlay from 'lib/components/modal-overlay.react.js'; import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types'; import { EditTextMessage } from './edit-text-message.react.js'; @@ -18,7 +19,7 @@ export type EditState = { +messageInfo: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +editedMessageDraft: ?string, +isError: boolean, +position?: ModalPosition, diff --git a/web/chat/edit-text-message.react.js b/web/chat/edit-text-message.react.js --- a/web/chat/edit-text-message.react.js +++ b/web/chat/edit-text-message.react.js @@ -8,6 +8,7 @@ import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { useEditMessage } from 'lib/shared/edit-messages-utils.js'; import { trimMessage } from 'lib/shared/message-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { editBoxBottomRowHeight } from './chat-constants.js'; @@ -20,7 +21,7 @@ type Props = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +background: boolean, }; diff --git a/web/chat/failed-send.react.js b/web/chat/failed-send.react.js --- a/web/chat/failed-send.react.js +++ b/web/chat/failed-send.react.js @@ -11,6 +11,7 @@ type RawComposableMessageInfo, assertComposableMessageType, } from 'lib/types/message-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import css from './chat-message-list.css'; @@ -22,7 +23,7 @@ type BaseProps = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type Props = { ...BaseProps, diff --git a/web/chat/inline-engagement.react.js b/web/chat/inline-engagement.react.js --- a/web/chat/inline-engagement.react.js +++ b/web/chat/inline-engagement.react.js @@ -18,7 +18,7 @@ type Props = { +messageInfo: MessageInfo, +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, - +sidebarThreadInfo: ?ThreadInfo, + +sidebarThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, +reactions: ReactionInfo, +positioning: 'left' | 'center' | 'right', +label?: ?string, diff --git a/web/chat/message.react.js b/web/chat/message.react.js --- a/web/chat/message.react.js +++ b/web/chat/message.react.js @@ -5,6 +5,7 @@ import { type ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { longAbsoluteDate } from 'lib/utils/date-utils.js'; @@ -17,7 +18,7 @@ type Props = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +shouldDisplayPinIndicator: boolean, }; function Message(props: Props): React.Node { diff --git a/web/chat/multimedia-message.react.js b/web/chat/multimedia-message.react.js --- a/web/chat/multimedia-message.react.js +++ b/web/chat/multimedia-message.react.js @@ -9,6 +9,7 @@ } from 'lib/media/media-utils.js'; import { type ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import css from './chat-message-list.css'; @@ -18,7 +19,7 @@ import Multimedia from '../media/multimedia.react.js'; type BaseProps = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +shouldDisplayPinIndicator: boolean, }; type Props = { diff --git a/web/chat/robotext-message.react.js b/web/chat/robotext-message.react.js --- a/web/chat/robotext-message.react.js +++ b/web/chat/robotext-message.react.js @@ -35,7 +35,7 @@ type Props = { +item: RobotextChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function RobotextMessage(props: Props): React.Node { let inlineEngagement; diff --git a/web/chat/text-message.react.js b/web/chat/text-message.react.js --- a/web/chat/text-message.react.js +++ b/web/chat/text-message.react.js @@ -8,6 +8,7 @@ import { colorIsDark } from 'lib/shared/color-utils.js'; import { onlyEmojiRegex } from 'lib/shared/emojis.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import css from './chat-message-list.css'; @@ -18,7 +19,7 @@ type Props = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +shouldDisplayPinIndicator: boolean, }; function TextMessage(props: Props): React.Node { diff --git a/web/chat/thread-menu.react.js b/web/chat/thread-menu.react.js --- a/web/chat/thread-menu.react.js +++ b/web/chat/thread-menu.react.js @@ -15,6 +15,7 @@ viewerIsMember, threadIsChannel, } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; @@ -35,7 +36,7 @@ import { useSelector } from '../redux/redux-utils.js'; type ThreadMenuProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function ThreadMenu(props: ThreadMenuProps): React.Node { diff --git a/web/chat/thread-top-bar.react.js b/web/chat/thread-top-bar.react.js --- a/web/chat/thread-top-bar.react.js +++ b/web/chat/thread-top-bar.react.js @@ -6,6 +6,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; import { threadIsPending } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; @@ -18,7 +19,7 @@ import MessageSearchModal from '../modals/search/message-search-modal.react.js'; type ThreadTopBarProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function ThreadTopBar(props: ThreadTopBarProps): React.Node { const { threadInfo } = props; diff --git a/web/components/message-result.react.js b/web/components/message-result.react.js --- a/web/components/message-result.react.js +++ b/web/components/message-result.react.js @@ -6,6 +6,7 @@ import { useThreadChatMentionCandidates } from 'lib/hooks/chat-mention-hooks.js'; import { useStringForUser } from 'lib/hooks/ens-cache.js'; import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { longAbsoluteDate } from 'lib/utils/date-utils.js'; @@ -16,7 +17,7 @@ type MessageResultProps = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +scrollable: boolean, }; diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -74,6 +74,7 @@ import type { RawImagesMessageInfo } from 'lib/types/messages/images.js'; import type { RawMediaMessageInfo } from 'lib/types/messages/media.js'; import type { RawTextMessageInfo } from 'lib/types/messages/text.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { reportTypes } from 'lib/types/report-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; @@ -544,7 +545,9 @@ } } - startThreadCreation(threadInfo: ThreadInfo): Promise { + startThreadCreation( + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + ): Promise { if (!threadIsPending(threadInfo.id)) { return Promise.resolve(threadInfo.id); } @@ -1280,10 +1283,17 @@ threadID: newThreadID, time: Date.now(), }; - const newThreadInfo = { - ...threadInfo, - id: newThreadID, - }; + + // Branching to appease `flow`. + const newThreadInfo = threadInfo.minimallyEncoded + ? { + ...threadInfo, + id: newThreadID, + } + : { + ...threadInfo, + id: newThreadID, + }; this.props.dispatchActionPromise( sendTextMessageActionTypes, this.sendTextMessageAction( @@ -1298,8 +1308,8 @@ async sendTextMessageAction( messageInfo: RawTextMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ): Promise { try { await this.props.textMessageCreationSideEffectsFunc( diff --git a/web/input/input-state.js b/web/input/input-state.js --- a/web/input/input-state.js +++ b/web/input/input-state.js @@ -9,6 +9,10 @@ type MediaMissionStep, } from 'lib/types/media-types.js'; import type { RawTextMessageInfo } from 'lib/types/messages/text.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo, RelativeMemberInfo, @@ -47,7 +51,9 @@ export type TypeaheadState = { +canBeVisible: boolean, +keepUpdatingThreadMembers: boolean, - +frozenUserMentionsCandidates: $ReadOnlyArray, + +frozenUserMentionsCandidates: $ReadOnlyArray< + RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, +frozenChatMentionsCandidates: ChatMentionCandidates, +moveChoiceUp: ?() => void, +moveChoiceDown: ?() => void, @@ -65,23 +71,26 @@ +textCursorPosition: number, +typeaheadState: TypeaheadState, +appendFiles: ( - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, files: $ReadOnlyArray, ) => Promise, +cancelPendingUpload: (localUploadID: string) => void, +sendTextMessage: ( messageInfo: RawTextMessageInfo, - threadInfo: ThreadInfo, - parentThreadInfo: ?ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + parentThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ) => Promise, - +createMultimediaMessage: (localID: number, threadInfo: ThreadInfo) => void, + +createMultimediaMessage: ( + localID: number, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + ) => void, +setDraft: (draft: string) => void, +setTextCursorPosition: (newPosition: number) => void, +setTypeaheadState: ($Shape) => void, +messageHasUploadFailure: (localMessageID: string) => boolean, +retryMultimediaMessage: ( localMessageID: string, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ) => void, +addReply: (text: string) => void, +addReplyListener: ((message: string) => void) => void, diff --git a/web/modals/chat/message-results-modal.react.js b/web/modals/chat/message-results-modal.react.js --- a/web/modals/chat/message-results-modal.react.js +++ b/web/modals/chat/message-results-modal.react.js @@ -14,6 +14,7 @@ isInvalidPinSourceForThread, modifyItemForResultScreen, } from 'lib/shared/message-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/action-utils.js'; @@ -24,7 +25,7 @@ import Modal from '../modal.react.js'; type MessageResultsModalProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +modalName: string, }; diff --git a/web/modals/chat/sidebar-promote-modal.react.js b/web/modals/chat/sidebar-promote-modal.react.js --- a/web/modals/chat/sidebar-promote-modal.react.js +++ b/web/modals/chat/sidebar-promote-modal.react.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; @@ -12,7 +13,7 @@ type Props = { +onClose: () => void, +onConfirm: () => void, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function SidebarPromoteModal(props: Props): React.Node { diff --git a/web/modals/chat/toggle-pin-modal.react.js b/web/modals/chat/toggle-pin-modal.react.js --- a/web/modals/chat/toggle-pin-modal.react.js +++ b/web/modals/chat/toggle-pin-modal.react.js @@ -11,6 +11,7 @@ import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { modifyItemForResultScreen } from 'lib/shared/message-utils.js'; import type { RawMessageInfo } from 'lib/types/message-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/action-utils.js'; @@ -21,7 +22,7 @@ type TogglePinModalProps = { +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function TogglePinModal(props: TogglePinModalProps): React.Node { diff --git a/web/modals/search/message-search-modal.react.js b/web/modals/search/message-search-modal.react.js --- a/web/modals/search/message-search-modal.react.js +++ b/web/modals/search/message-search-modal.react.js @@ -3,6 +3,7 @@ import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; @@ -17,7 +18,7 @@ import Modal from '../modal.react.js'; type ContentProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function MessageSearchModal(props: ContentProps): React.Node { diff --git a/web/modals/threads/confirm-leave-thread-modal.react.js b/web/modals/threads/confirm-leave-thread-modal.react.js --- a/web/modals/threads/confirm-leave-thread-modal.react.js +++ b/web/modals/threads/confirm-leave-thread-modal.react.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; @@ -10,7 +11,7 @@ import Modal from '../modal.react.js'; type Props = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +onClose: () => void, +onConfirm: () => void, }; diff --git a/web/modals/threads/create/compose-subchannel-modal.react.js b/web/modals/threads/create/compose-subchannel-modal.react.js --- a/web/modals/threads/create/compose-subchannel-modal.react.js +++ b/web/modals/threads/create/compose-subchannel-modal.react.js @@ -7,6 +7,7 @@ newThreadActionTypes, } from 'lib/actions/thread-actions.js'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/action-utils.js'; @@ -24,7 +25,7 @@ type Props = { +onClose: () => void, - +parentThreadInfo: ThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; const getThreadType = (visibility: VisibilityType, announcement: boolean) => { diff --git a/web/modals/threads/create/steps/subchannel-members-list.react.js b/web/modals/threads/create/steps/subchannel-members-list.react.js --- a/web/modals/threads/create/steps/subchannel-members-list.react.js +++ b/web/modals/threads/create/steps/subchannel-members-list.react.js @@ -5,6 +5,7 @@ import { useENSNames } from 'lib/hooks/ens-cache.js'; import { stringForUser } from 'lib/shared/user-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import type { UserListItem } from 'lib/types/user-types.js'; @@ -13,8 +14,8 @@ type Props = { +searchText: string, +searchResult: $ReadOnlySet, - +communityThreadInfo: ThreadInfo, - +parentThreadInfo: ThreadInfo, + +communityThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +selectedUsers: $ReadOnlySet, +toggleUserSelection: (userID: string) => void, }; @@ -29,10 +30,7 @@ toggleUserSelection, } = props; - const { members: parentMembers } = parentThreadInfo; - - const { members: communityMembers, name: communityName } = - communityThreadInfo; + const { name: communityName } = communityThreadInfo; const currentUserId = useSelector(state => state.currentUserInfo.id); @@ -41,40 +39,67 @@ [parentThreadInfo], ); - const parentMemberListWithoutENSNames = React.useMemo( - () => - parentMembers + const parentMemberListWithoutENSNames = React.useMemo(() => { + // Branching to appease `flow`. + if (parentThreadInfo.minimallyEncoded) { + return parentThreadInfo.members + .filter( + user => + user.id !== currentUserId && + (searchResult.has(user.id) || searchText.length === 0), + ) + .map(user => ({ id: user.id, username: stringForUser(user) })); + } else { + return parentThreadInfo.members .filter( user => user.id !== currentUserId && (searchResult.has(user.id) || searchText.length === 0), ) - .map(user => ({ id: user.id, username: stringForUser(user) })), + .map(user => ({ id: user.id, username: stringForUser(user) })); + } + }, [ + currentUserId, + parentThreadInfo.members, + parentThreadInfo.minimallyEncoded, + searchResult, + searchText.length, + ]); - [parentMembers, currentUserId, searchResult, searchText], - ); const parentMemberList = useENSNames( parentMemberListWithoutENSNames, ); - const otherMemberListWithoutENSNames = React.useMemo( - () => - communityMembers + const otherMemberListWithoutENSNames = React.useMemo(() => { + // Branching to appease `flow`. + if (communityThreadInfo.minimallyEncoded) { + return communityThreadInfo.members .filter( user => !parentMembersSet.has(user.id) && user.id !== currentUserId && (searchResult.has(user.id) || searchText.length === 0), ) - .map(user => ({ id: user.id, username: stringForUser(user) })), - [ - communityMembers, - parentMembersSet, - currentUserId, - searchResult, - searchText, - ], - ); + .map(user => ({ id: user.id, username: stringForUser(user) })); + } else { + return communityThreadInfo.members + .filter( + user => + !parentMembersSet.has(user.id) && + user.id !== currentUserId && + (searchResult.has(user.id) || searchText.length === 0), + ) + .map(user => ({ id: user.id, username: stringForUser(user) })); + } + }, [ + communityThreadInfo.members, + communityThreadInfo.minimallyEncoded, + currentUserId, + parentMembersSet, + searchResult, + searchText.length, + ]); + const otherMemberList = useENSNames( otherMemberListWithoutENSNames, ); diff --git a/web/modals/threads/create/steps/subchannel-members.react.js b/web/modals/threads/create/steps/subchannel-members.react.js --- a/web/modals/threads/create/steps/subchannel-members.react.js +++ b/web/modals/threads/create/steps/subchannel-members.react.js @@ -5,6 +5,7 @@ import { userStoreSearchIndex } from 'lib/selectors/user-selectors.js'; import { useAncestorThreads } from 'lib/shared/ancestor-threads.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import MembersList from './subchannel-members-list.react.js'; @@ -12,7 +13,7 @@ import Search from '../../../../components/search.react.js'; type SubchannelMembersProps = { - +parentThreadInfo: ThreadInfo, + +parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo, +selectedUsers: $ReadOnlySet, +searchText: string, +setSearchText: string => void, diff --git a/web/navigation-panels/chat-thread-ancestors.react.js b/web/navigation-panels/chat-thread-ancestors.react.js --- a/web/navigation-panels/chat-thread-ancestors.react.js +++ b/web/navigation-panels/chat-thread-ancestors.react.js @@ -5,13 +5,14 @@ import { ChevronRight } from 'react-feather'; import { useAncestorThreads } from 'lib/shared/ancestor-threads.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; import css from './chat-thread-ancestors.css'; type ThreadAncestorsProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function ThreadAncestors(props: ThreadAncestorsProps): React.Node { const { threadInfo } = props; diff --git a/web/navigation-panels/nav-state-info-bar.react.js b/web/navigation-panels/nav-state-info-bar.react.js --- a/web/navigation-panels/nav-state-info-bar.react.js +++ b/web/navigation-panels/nav-state-info-bar.react.js @@ -3,6 +3,7 @@ import classnames from 'classnames'; import * as React from 'react'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import ThreadAncestors from './chat-thread-ancestors.react.js'; @@ -10,7 +11,7 @@ import ThreadAvatar from '../avatars/thread-avatar.react.js'; type NavStateInfoBarProps = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function NavStateInfoBar(props: NavStateInfoBarProps): React.Node { const { threadInfo } = props; @@ -26,7 +27,7 @@ } type PossiblyEmptyNavStateInfoBarProps = { - +threadInfoInput: ?ThreadInfo, + +threadInfoInput: ?ThreadInfo | ?MinimallyEncodedThreadInfo, }; function PossiblyEmptyNavStateInfoBar( props: PossiblyEmptyNavStateInfoBarProps, diff --git a/web/selectors/thread-selectors.js b/web/selectors/thread-selectors.js --- a/web/selectors/thread-selectors.js +++ b/web/selectors/thread-selectors.js @@ -66,7 +66,7 @@ function useOnClickPendingSidebar( messageInfo: ComposableMessageInfo | RobotextMessageInfo, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): (event: SyntheticEvent) => mixed { const dispatch = useDispatch(); const loggedInUserInfo = useLoggedInUserInfo(); diff --git a/web/utils/thread-utils.js b/web/utils/thread-utils.js --- a/web/utils/thread-utils.js +++ b/web/utils/thread-utils.js @@ -10,6 +10,7 @@ createPendingThread, useExistingThreadInfoFinder, } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import { type ThreadInfo } from 'lib/types/thread-types.js'; import type { AccountUserInfo } from 'lib/types/user-types.js'; @@ -39,7 +40,7 @@ function useThreadInfoForPossiblyPendingThread( activeChatThreadID: ?string, -): ?ThreadInfo { +): ?ThreadInfo | ?MinimallyEncodedThreadInfo { const { isChatCreation, selectedUserInfos } = useInfosForPendingThread(); const loggedInUserInfo = useLoggedInUserInfo(); diff --git a/web/utils/tooltip-action-utils.js b/web/utils/tooltip-action-utils.js --- a/web/utils/tooltip-action-utils.js +++ b/web/utils/tooltip-action-utils.js @@ -17,6 +17,7 @@ useSidebarExistsOrCanBeCreated, } from 'lib/shared/thread-utils.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import { longAbsoluteDate } from 'lib/utils/date-utils.js'; @@ -125,7 +126,7 @@ function useMessageTooltipSidebarAction( item: ChatMessageInfoItem, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): ?MessageTooltipAction { const { threadCreatedFromMessage, messageInfo } = item; const { popModal } = useModalContext(); @@ -167,7 +168,7 @@ function useMessageTooltipReplyAction( item: ChatMessageInfoItem, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): ?MessageTooltipAction { const { messageInfo } = item; const { popModal } = useModalContext(); @@ -232,7 +233,7 @@ function useMessageReactAction( item: ChatMessageInfoItem, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): ?MessageTooltipAction { const { messageInfo } = item; @@ -267,7 +268,7 @@ function useMessageTogglePinAction( item: ChatMessageInfoItem, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): ?MessageTooltipAction { const { pushModal } = useModalContext(); const { messageInfo, isPinned } = item; @@ -303,7 +304,7 @@ function useMessageEditAction( item: ChatMessageInfoItem, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): ?MessageTooltipAction { const { messageInfo } = item; @@ -346,7 +347,7 @@ function useMessageTooltipActions( item: ChatMessageInfoItem, - threadInfo: ThreadInfo, + threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): $ReadOnlyArray { const sidebarAction = useMessageTooltipSidebarAction(item, threadInfo); const replyAction = useMessageTooltipReplyAction(item, threadInfo); @@ -383,7 +384,7 @@ type UseMessageTooltipArgs = { +availablePositions: $ReadOnlyArray, +item: ChatMessageInfoItem, - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; function useMessageTooltip({