diff --git a/lib/components/chat-mention-provider.react.js b/lib/components/chat-mention-provider.react.js --- a/lib/components/chat-mention-provider.react.js +++ b/lib/components/chat-mention-provider.react.js @@ -5,7 +5,10 @@ import genesis from '../facts/genesis.js'; import { threadInfoSelector } from '../selectors/thread-selectors.js'; import SentencePrefixSearchIndex from '../shared/sentence-prefix-search-index.js'; -import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedResolvedThreadInfo, + MinimallyEncodedThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from '../types/thread-types-enum.js'; import type { ChatMentionCandidates, @@ -73,7 +76,7 @@ } function getChatMentionCandidates(threadInfos: { - +[id: string]: ResolvedThreadInfo, + +[id: string]: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, }): { chatMentionCandidatesObj: ChatMentionCandidatesObj, communityThreadIDForGenesisThreads: { +[id: string]: string }, diff --git a/lib/permissions/minimally-encoded-thread-permissions-validators.js b/lib/permissions/minimally-encoded-thread-permissions-validators.js --- a/lib/permissions/minimally-encoded-thread-permissions-validators.js +++ b/lib/permissions/minimally-encoded-thread-permissions-validators.js @@ -9,6 +9,7 @@ MinimallyEncodedMemberInfo, MinimallyEncodedRawThreadInfo, MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedResolvedThreadInfo, MinimallyEncodedRoleInfo, MinimallyEncodedThreadCurrentUserInfo, MinimallyEncodedThreadInfo, @@ -59,6 +60,12 @@ currentUser: minimallyEncodedThreadCurrentUserInfoValidator, }); +const minimallyEncodedResolvedThreadInfoValidator: TInterface = + tShape({ + ...minimallyEncodedThreadInfoValidator.meta.props, + uiName: t.String, + }); + const minimallyEncodedRawThreadInfoValidator: TInterface = tShape({ ...rawThreadInfoValidator.meta.props, @@ -74,5 +81,6 @@ minimallyEncodedMemberInfoValidator, minimallyEncodedRelativeMemberInfoValidator, minimallyEncodedThreadInfoValidator, + minimallyEncodedResolvedThreadInfoValidator, minimallyEncodedRawThreadInfoValidator, }; diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js --- a/lib/shared/markdown.js +++ b/lib/shared/markdown.js @@ -6,7 +6,10 @@ markdownUserMentionRegex, decodeChatMentionText, } from './mention-utils.js'; -import type { MinimallyEncodedRelativeMemberInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + MinimallyEncodedResolvedThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import type { RelativeMemberInfo, ResolvedThreadInfo, @@ -259,7 +262,7 @@ chatMentionCandidates: ChatMentionCandidates, capture: Capture, ): { - threadInfo: ?ResolvedThreadInfo, + threadInfo: ?ResolvedThreadInfo | ?MinimallyEncodedResolvedThreadInfo, content: string, hasAccessToChat: 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,6 +4,7 @@ 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 { threadTypes } from '../types/thread-types-enum.js'; import type { ThreadInfo, @@ -30,7 +31,7 @@ type MentionTypeaheadChatSuggestionItem = { +type: 'chat', - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, }; export type MentionTypeaheadSuggestionItem = @@ -70,7 +71,9 @@ return text.replace(/\\]/g, ']'); } -function getRawChatMention(threadInfo: ResolvedThreadInfo): string { +function getRawChatMention( + threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +): string { return `@[[${threadInfo.id}:${encodeChatMentionText(threadInfo.uiName)}]]`; } diff --git a/lib/types/filter-types.js b/lib/types/filter-types.js --- a/lib/types/filter-types.js +++ b/lib/types/filter-types.js @@ -2,6 +2,7 @@ import t, { type TUnion } from 'tcomb'; +import type { MinimallyEncodedResolvedThreadInfo } from './minimally-encoded-thread-permissions-types.js'; import type { ResolvedThreadInfo } from './thread-types.js'; import { tID, tShape, tString } from '../utils/validation-utils.js'; @@ -40,6 +41,6 @@ }; export type FilterThreadInfo = { - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +numVisibleEntries: number, }; diff --git a/lib/types/minimally-encoded-thread-permissions-types.js b/lib/types/minimally-encoded-thread-permissions-types.js --- a/lib/types/minimally-encoded-thread-permissions-types.js +++ b/lib/types/minimally-encoded-thread-permissions-types.js @@ -189,6 +189,11 @@ }; }; +export type MinimallyEncodedResolvedThreadInfo = $ReadOnly<{ + ...MinimallyEncodedThreadInfo, + +uiName: string, +}>; + export { minimallyEncodeRoleInfo, decodeMinimallyEncodedRoleInfo, 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 @@ -15,6 +15,7 @@ MessageTruncationStatuses, RawMessageInfo, } from './message-types.js'; +import type { MinimallyEncodedResolvedThreadInfo } from './minimally-encoded-thread-permissions-types.js'; import { type ThreadSubscription, threadSubscriptionValidator, @@ -461,7 +462,9 @@ export type ThreadStoreThreadInfos = RawThreadInfos; -export type ChatMentionCandidates = { +[id: string]: ResolvedThreadInfo }; +export type ChatMentionCandidates = { + +[id: string]: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +}; export type ChatMentionCandidatesObj = { +[id: string]: ChatMentionCandidates, }; diff --git a/native/avatars/edit-thread-avatar.react.js b/native/avatars/edit-thread-avatar.react.js --- a/native/avatars/edit-thread-avatar.react.js +++ b/native/avatars/edit-thread-avatar.react.js @@ -6,7 +6,10 @@ import { ActivityIndicator, TouchableOpacity, View } from 'react-native'; import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js'; -import type { MinimallyEncodedRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRawThreadInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import { @@ -26,7 +29,7 @@ +threadInfo: | RawThreadInfo | ThreadInfo - | MinimallyEncodedRawThreadInfo + | MinimallyEncodedThreadInfo | MinimallyEncodedRawThreadInfo, +disabled?: boolean, }; diff --git a/native/avatars/thread-avatar.react.js b/native/avatars/thread-avatar.react.js --- a/native/avatars/thread-avatar.react.js +++ b/native/avatars/thread-avatar.react.js @@ -10,6 +10,7 @@ import type { AvatarSize } from 'lib/types/avatar-types.js'; import type { MinimallyEncodedRawThreadInfo, + MinimallyEncodedResolvedThreadInfo, MinimallyEncodedThreadInfo, } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; @@ -28,7 +29,8 @@ | ThreadInfo | ResolvedThreadInfo | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + | MinimallyEncodedThreadInfo + | MinimallyEncodedResolvedThreadInfo, +size: AvatarSize, }; diff --git a/native/chat/settings/delete-thread.react.js b/native/chat/settings/delete-thread.react.js --- a/native/chat/settings/delete-thread.react.js +++ b/native/chat/settings/delete-thread.react.js @@ -25,6 +25,10 @@ getThreadsToDeleteText, } from 'lib/shared/thread-utils.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; +import type { + MinimallyEncodedResolvedThreadInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo, ResolvedThreadInfo, @@ -49,7 +53,7 @@ import type { ChatNavigationProp } from '../chat.react.js'; export type DeleteThreadParams = { - +threadInfo: ThreadInfo, + +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, }; type BaseProps = { @@ -59,7 +63,7 @@ type Props = { ...BaseProps, // Redux state - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +shouldUseDeleteConfirmationAlert: boolean, +loadingStatus: LoadingStatus, +colors: Colors, diff --git a/native/chat/settings/thread-settings-avatar.react.js b/native/chat/settings/thread-settings-avatar.react.js --- a/native/chat/settings/thread-settings-avatar.react.js +++ b/native/chat/settings/thread-settings-avatar.react.js @@ -3,13 +3,14 @@ import * as React from 'react'; import { View } from 'react-native'; +import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ResolvedThreadInfo } from 'lib/types/thread-types.js'; import EditThreadAvatar from '../../avatars/edit-thread-avatar.react.js'; import { useStyles } from '../../themes/colors.js'; type Props = { - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +canChangeSettings: boolean, }; function ThreadSettingsAvatar(props: Props): React.Node { diff --git a/native/chat/settings/thread-settings-delete-thread.react.js b/native/chat/settings/thread-settings-delete-thread.react.js --- a/native/chat/settings/thread-settings-delete-thread.react.js +++ b/native/chat/settings/thread-settings-delete-thread.react.js @@ -3,6 +3,7 @@ import * as React from 'react'; import { Text, View } from 'react-native'; +import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ResolvedThreadInfo } from 'lib/types/thread-types.js'; import type { ThreadSettingsNavigate } from './thread-settings.react.js'; @@ -12,7 +13,7 @@ import type { ViewStyle } from '../../types/styles.js'; type Props = { - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +navigate: ThreadSettingsNavigate, +buttonStyle: ViewStyle, }; diff --git a/native/chat/settings/thread-settings-name.react.js b/native/chat/settings/thread-settings-name.react.js --- a/native/chat/settings/thread-settings-name.react.js +++ b/native/chat/settings/thread-settings-name.react.js @@ -15,6 +15,7 @@ } from 'lib/actions/thread-actions.js'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; +import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type ResolvedThreadInfo, type ChangeThreadSettingsPayload, @@ -36,7 +37,7 @@ import Alert from '../../utils/alert.js'; type BaseProps = { - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +nameEditValue: ?string, +setNameEditValue: (value: ?string, callback?: () => void) => void, +canChangeSettings: boolean, 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 @@ -28,7 +28,10 @@ threadIsChannel, } from 'lib/shared/thread-utils.js'; import threadWatcher from 'lib/shared/thread-watcher.js'; -import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedResolvedThreadInfo, + MinimallyEncodedThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { RelationshipButton } from 'lib/types/relationship-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; @@ -131,20 +134,20 @@ | { +itemType: 'avatar', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +canChangeSettings: boolean, } | { +itemType: 'name', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +nameEditValue: ?string, +canChangeSettings: boolean, } | { +itemType: 'color', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +colorEditValue: string, +canChangeSettings: boolean, +navigate: ThreadSettingsNavigate, @@ -153,7 +156,7 @@ | { +itemType: 'description', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +descriptionEditValue: ?string, +descriptionTextHeight: ?number, +canChangeSettings: boolean, @@ -167,17 +170,17 @@ | { +itemType: 'visibility', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, } | { +itemType: 'pushNotifs', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, } | { +itemType: 'homeNotifs', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, } | { +itemType: 'seeMore', @@ -221,14 +224,14 @@ | { +itemType: 'promoteSidebar' | 'leaveThread' | 'deleteThread', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +navigate: ThreadSettingsNavigate, +buttonStyle: ViewStyle, } | { +itemType: 'editRelationship', +key: string, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +navigate: ThreadSettingsNavigate, +buttonStyle: ViewStyle, +relationshipButton: RelationshipButton, diff --git a/native/components/thread-list-thread.react.js b/native/components/thread-list-thread.react.js --- a/native/components/thread-list-thread.react.js +++ b/native/components/thread-list-thread.react.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ThreadInfo, ResolvedThreadInfo } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; @@ -22,7 +23,7 @@ }; type Props = { ...SharedProps, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +colors: Colors, +styles: typeof unboundStyles, }; diff --git a/web/calendar/entry.react.js b/web/calendar/entry.react.js --- a/web/calendar/entry.react.js +++ b/web/calendar/entry.react.js @@ -36,6 +36,7 @@ type 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 type { ResolvedThreadInfo } from 'lib/types/thread-types.js'; @@ -65,7 +66,7 @@ }; type Props = { ...BaseProps, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +loggedIn: boolean, +calendarQuery: () => CalendarQuery, +online: boolean, diff --git a/web/markdown/markdown-chat-mention.react.js b/web/markdown/markdown-chat-mention.react.js --- a/web/markdown/markdown-chat-mention.react.js +++ b/web/markdown/markdown-chat-mention.react.js @@ -2,13 +2,14 @@ import * as React from 'react'; +import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ResolvedThreadInfo } from 'lib/types/thread-types.js'; import css from './markdown.css'; import { useOnClickThread } from '../selectors/thread-selectors.js'; type MarkdownChatMentionProps = { - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +hasAccessToChat: boolean, +text: string, }; diff --git a/web/modals/history/history-entry.react.js b/web/modals/history/history-entry.react.js --- a/web/modals/history/history-entry.react.js +++ b/web/modals/history/history-entry.react.js @@ -19,6 +19,7 @@ type 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 { ResolvedThreadInfo } from 'lib/types/thread-types.js'; import type { UserInfo } from 'lib/types/user-types.js'; import { @@ -39,7 +40,7 @@ }; type Props = { ...BaseProps, - +threadInfo: ResolvedThreadInfo, + +threadInfo: ResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo, +loggedIn: boolean, +restoreLoadingStatus: LoadingStatus, +calendarQuery: () => CalendarQuery,