diff --git a/lib/selectors/nav-selectors.js b/lib/selectors/nav-selectors.js --- a/lib/selectors/nav-selectors.js +++ b/lib/selectors/nav-selectors.js @@ -14,11 +14,12 @@ import type { CalendarFilter } from '../types/filter-types.js'; import type { ThreadInfo, + MinimallyEncodedRelativeMemberInfo, RawThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import type { BaseNavInfo } from '../types/nav-types.js'; import type { BaseAppState } from '../types/redux-types.js'; -import type { RelativeMemberInfo } from '../types/thread-types'; +import type { LegacyRelativeMemberInfo } from '../types/thread-types'; import type { UserInfo } from '../types/user-types.js'; import { getConfig } from '../utils/config.js'; import { values } from '../utils/objects.js'; @@ -83,12 +84,17 @@ const useENSNamesOptions = { allAtOnce: true }; function useUserSearchIndex( - userInfos: $ReadOnlyArray, + userInfos: $ReadOnlyArray< + UserInfo | LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ): SearchIndex { const membersWithENSNames = useENSNames(userInfos, useENSNamesOptions); const memberMap = React.useMemo(() => { - const result = new Map(); + const result = new Map< + string, + UserInfo | LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >(); for (const userInfo of membersWithENSNames) { result.set(userInfo.id, userInfo); } diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js --- a/lib/selectors/thread-selectors.js +++ b/lib/selectors/thread-selectors.js @@ -25,38 +25,39 @@ import { createEntryInfo } from '../shared/entry-utils.js'; import { getMostRecentNonLocalMessageID } from '../shared/message-utils.js'; import { - threadInHomeChatList, + getPendingThreadID, + roleIsAdminRole, + threadHasAdminRole, + threadHasPermission, threadInBackgroundChatList, + threadInChatList, threadInFilterList, threadInfoFromRawThreadInfo, - threadHasPermission, - threadInChatList, - threadHasAdminRole, - roleIsAdminRole, + threadInHomeChatList, threadIsPending, - getPendingThreadID, } from '../shared/thread-utils.js'; import type { ClientAvatar, ClientEmojiAvatar } from '../types/avatar-types'; import type { EntryInfo } from '../types/entry-types.js'; import type { MessageStore, RawMessageInfo } from '../types/message-types.js'; import type { - ThreadInfo, + MinimallyEncodedRelativeMemberInfo, RawThreadInfo, + ThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import type { BaseAppState } from '../types/redux-types.js'; import { threadPermissions } from '../types/thread-permission-types.js'; import { - threadTypes, - threadTypeIsCommunityRoot, type ThreadType, + threadTypeIsCommunityRoot, + threadTypes, } from '../types/thread-types-enum.js'; import type { - SidebarInfo, - RelativeMemberInfo, + LegacyRelativeMemberInfo, MixedRawThreadInfos, RawThreadInfos, + SidebarInfo, } from '../types/thread-types.js'; -import { dateString, dateFromString } from '../utils/date-utils.js'; +import { dateFromString, dateString } from '../utils/date-utils.js'; import { values } from '../utils/objects.js'; const _mapValuesWithKeys = _mapValues.convert({ cap: false }); @@ -351,7 +352,9 @@ relativeMemberInfoSelectorForMembersOfThread(threadID), ( threadInfo: ?RawThreadInfo, - members: $ReadOnlyArray, + members: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ): boolean => { if (!threadInfo) { return false; diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js --- a/lib/selectors/user-selectors.js +++ b/lib/selectors/user-selectors.js @@ -9,20 +9,23 @@ } from '../shared/avatar-utils.js'; import { getSingleOtherUser } from '../shared/thread-utils.js'; import type { ClientEmojiAvatar } from '../types/avatar-types'; -import type { RawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + RawThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import type { BaseAppState } from '../types/redux-types.js'; import { userRelationshipStatus } from '../types/relationship-types.js'; import { threadTypes } from '../types/thread-types-enum.js'; import type { LegacyRawThreadInfo, - RelativeMemberInfo, + LegacyRelativeMemberInfo, RawThreadInfos, } from '../types/thread-types.js'; import type { - UserInfos, - RelativeUserInfo, AccountUserInfo, CurrentUserInfo, + RelativeUserInfo, + UserInfos, } from '../types/user-types.js'; // Used for specific message payloads that include an array of user IDs, ie. @@ -106,14 +109,18 @@ return relativeMemberInfos; } -const emptyArray: $ReadOnlyArray = []; +const emptyArray: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +> = []; // Includes current user at the start const baseRelativeMemberInfoSelectorForMembersOfThread: ( threadID: ?string, -) => (state: BaseAppState<>) => $ReadOnlyArray = ( - threadID: ?string, -) => { +) => ( + state: BaseAppState<>, +) => $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +> = (threadID: ?string) => { if (!threadID) { return () => emptyArray; } @@ -128,9 +135,11 @@ const relativeMemberInfoSelectorForMembersOfThread: ( threadID: ?string, -) => (state: BaseAppState<>) => $ReadOnlyArray = _memoize( - baseRelativeMemberInfoSelectorForMembersOfThread, -); +) => ( + state: BaseAppState<>, +) => $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +> = _memoize(baseRelativeMemberInfoSelectorForMembersOfThread); const userInfoSelectorForPotentialMembers: (state: BaseAppState<>) => { [id: string]: AccountUserInfo, diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js --- a/lib/shared/markdown.js +++ b/lib/shared/markdown.js @@ -8,10 +8,13 @@ decodeChatMentionText, } from './mention-utils.js'; import { useENSNames } from '../hooks/ens-cache.js'; -import type { ResolvedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ResolvedThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import type { ChatMentionCandidates, - RelativeMemberInfo, + LegacyRelativeMemberInfo, } from '../types/thread-types.js'; // simple-markdown types @@ -201,7 +204,9 @@ const useENSNamesOptions = { allAtOnce: true }; function useMemberMapForUserMentions( - members: $ReadOnlyArray, + members: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ): $ReadOnlyMap { const membersWithRole = React.useMemo( () => members.filter(member => member.role), @@ -209,11 +214,13 @@ ); const resolvedMembers = useENSNames(membersWithRole, useENSNamesOptions); - const resolvedMembersMap: $ReadOnlyMap = - React.useMemo( - () => new Map(resolvedMembers.map(member => [member.id, member])), - [resolvedMembers], - ); + const resolvedMembersMap: $ReadOnlyMap< + string, + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + > = React.useMemo( + () => new Map(resolvedMembers.map(member => [member.id, member])), + [resolvedMembers], + ); const membersMap = React.useMemo(() => { const map = new Map(); 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 @@ -8,13 +8,14 @@ import { useENSNames } from '../hooks/ens-cache.js'; import { useUserSearchIndex } from '../selectors/nav-selectors.js'; import type { + MinimallyEncodedRelativeMemberInfo, ResolvedThreadInfo, ThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from '../types/thread-types-enum.js'; import type { ChatMentionCandidates, - RelativeMemberInfo, + LegacyRelativeMemberInfo, } from '../types/thread-types.js'; import { chatNameMaxLength, idSchemaRegex } from '../utils/validation-utils.js'; @@ -30,7 +31,7 @@ type MentionTypeaheadUserSuggestionItem = { +type: 'user', - +userInfo: RelativeMemberInfo, + +userInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, }; type MentionTypeaheadChatSuggestionItem = { @@ -107,7 +108,9 @@ const useENSNamesOptions = { allAtOnce: true }; function useMentionTypeaheadUserSuggestions( - threadMembers: $ReadOnlyArray, + threadMembers: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, typeaheadMatchedStrings: ?TypeaheadMatchedStrings, ): $ReadOnlyArray { const userSearchIndex = useUserSearchIndex(threadMembers); @@ -186,7 +189,9 @@ function useUserMentionsCandidates( threadInfo: ThreadInfo, parentThreadInfo: ?ThreadInfo, -): $ReadOnlyArray { +): $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +> { return React.useMemo(() => { if (threadInfo.type !== threadTypes.SIDEBAR) { return threadInfo.members; 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 @@ -58,6 +58,7 @@ type ComposableMessageInfo, } from '../types/message-types.js'; import type { + MinimallyEncodedRelativeMemberInfo, MinimallyEncodedRoleInfo, RawThreadInfo, MinimallyEncodedThreadCurrentUserInfo, @@ -89,6 +90,7 @@ } from '../types/thread-types-enum.js'; import type { LegacyRawThreadInfo, + LegacyRelativeMemberInfo, MemberInfo, ServerThreadInfo, RoleInfo, @@ -97,7 +99,6 @@ NewThreadResult, ChangeThreadSettingsPayload, UserProfileThreadInfo, - RelativeMemberInfo, MixedRawThreadInfos, } from '../types/thread-types.js'; import { updateTypes } from '../types/update-types-enum.js'; @@ -219,17 +220,18 @@ } function threadActualMembers( - memberInfos: $ReadOnlyArray, + memberInfos: $ReadOnlyArray< + MemberInfo | LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ): $ReadOnlyArray { return memberInfos .filter(memberInfo => memberInfo.role) .map(memberInfo => memberInfo.id); } -function threadOtherMembers( - memberInfos: $ReadOnlyArray, - viewerID: ?string, -): $ReadOnlyArray { +function threadOtherMembers< + T: MemberInfo | LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +>(memberInfos: $ReadOnlyArray, viewerID: ?string): $ReadOnlyArray { return memberInfos.filter( memberInfo => memberInfo.role && memberInfo.id !== viewerID, ); @@ -459,7 +461,9 @@ // Returns map from lowercase username to AccountUserInfo function memberLowercaseUsernameMap( - members: $ReadOnlyArray, + members: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ): Map { const memberMap = new Map(); for (const member of members) { @@ -877,8 +881,9 @@ return firstLine(threadInfo.name); } - const threadMembers: $ReadOnlyArray = - threadInfo.members.filter(memberInfo => memberInfo.role); + const threadMembers: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + > = threadInfo.members.filter(memberInfo => memberInfo.role); const memberEntities: $ReadOnlyArray = threadMembers.map(member => ET.user({ userInfo: member }), ); @@ -1030,7 +1035,11 @@ // Since we don't have access to all of the ancestor ThreadInfos, we approximate // "parent admin" as anybody with CHANGE_ROLE permissions. function memberHasAdminPowers( - memberInfo: RelativeMemberInfo | MemberInfo | ServerMemberInfo, + memberInfo: + | LegacyRelativeMemberInfo + | MinimallyEncodedRelativeMemberInfo + | MemberInfo + | ServerMemberInfo, ): boolean { if (memberInfo.minimallyEncoded) { return hasPermission(memberInfo.permissions, threadPermissions.CHANGE_ROLE); @@ -1511,7 +1520,7 @@ function removeMemberFromThread( threadInfo: ThreadInfo, - memberInfo: RelativeMemberInfo, + memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, dispatchActionPromise: DispatchActionPromise, removeUserFromThreadServerCall: ( input: RemoveUsersFromThreadInput, @@ -1529,7 +1538,7 @@ } function getAvailableThreadMemberActions( - memberInfo: RelativeMemberInfo, + memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, threadInfo: ThreadInfo, canEdit: ?boolean = true, ): $ReadOnlyArray<'change_role' | 'remove_user'> { 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 @@ -17,7 +17,6 @@ import type { MinimallyEncodedMemberInfo, RawThreadInfo, - MinimallyEncodedRelativeMemberInfo, ResolvedThreadInfo, MinimallyEncodedRoleInfo, ThreadInfo, @@ -61,10 +60,6 @@ +isViewer: boolean, }>; -export type RelativeMemberInfo = - | LegacyRelativeMemberInfo - | MinimallyEncodedRelativeMemberInfo; - export type LegacyRoleInfo = { +id: string, +name: string, diff --git a/lib/utils/role-utils.js b/lib/utils/role-utils.js --- a/lib/utils/role-utils.js +++ b/lib/utils/role-utils.js @@ -4,13 +4,16 @@ import { useSelector } from './redux-utils.js'; import { threadInfoSelector } from '../selectors/thread-selectors.js'; -import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from '../types/minimally-encoded-thread-permissions-types.js'; import { configurableCommunityPermissions, type ThreadRolePermissionsBlob, type UserSurfacedPermission, } from '../types/thread-permission-types.js'; -import type { RelativeMemberInfo, RoleInfo } from '../types/thread-types'; +import type { LegacyRelativeMemberInfo, RoleInfo } from '../types/thread-types'; import { threadTypes } from '../types/thread-types-enum.js'; function constructRoleDeletionMessagePrompt( @@ -54,7 +57,9 @@ function useRolesFromCommunityThreadInfo( threadInfo: ThreadInfo, - memberInfos: $ReadOnlyArray, + memberInfos: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ): $ReadOnlyMap { // Our in-code system has chat-specific roles, while the // user-surfaced system has roles only for communities. We retrieve roles 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 @@ -73,13 +73,16 @@ MessageInfo, SendEditMessageResponse, } from 'lib/types/message-types.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} 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 { ChatMentionCandidates, ClientThreadJoinRequest, - RelativeMemberInfo, + LegacyRelativeMemberInfo, ThreadJoinPayload, } from 'lib/types/thread-types.js'; import { type UserInfos } from 'lib/types/user-types.js'; @@ -294,7 +297,9 @@ +dispatchActionPromise: DispatchActionPromise, +joinThread: (request: ClientThreadJoinRequest) => Promise, +inputState: ?InputState, - +userMentionsCandidates: $ReadOnlyArray, + +userMentionsCandidates: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, +chatMentionSearchIndex: SentencePrefixSearchIndex, +chatMentionCandidates: ChatMentionCandidates, +parentThreadInfo: ?ThreadInfo, 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,8 +5,11 @@ 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 { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import ThreadSettingsMemberTooltipButton from './thread-settings-member-tooltip-button.react.js'; @@ -22,7 +25,7 @@ import Alert from '../../utils/alert.js'; export type ThreadSettingsMemberTooltipModalParams = TooltipParams<{ - +memberInfo: RelativeMemberInfo, + +memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +threadInfo: ThreadInfo, }>; 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,8 +19,11 @@ 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 { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import { useRolesFromCommunityThreadInfo } from 'lib/utils/role-utils.js'; import type { ThreadSettingsNavigate } from './thread-settings.react.js'; @@ -87,7 +90,7 @@ }; type BaseProps = { - +memberInfo: RelativeMemberInfo, + +memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +threadInfo: ThreadInfo, +canEdit: boolean, +navigate: ThreadSettingsNavigate, 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 @@ -34,13 +34,14 @@ } from 'lib/shared/thread-utils.js'; import threadWatcher from 'lib/shared/thread-watcher.js'; import type { + MinimallyEncodedRelativeMemberInfo, ResolvedThreadInfo, ThreadInfo, } 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'; -import type { RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import type { UserInfos } from 'lib/types/user-types.js'; import { useResolvedOptionalThreadInfo, @@ -203,7 +204,9 @@ | { +itemType: 'member', +key: string, - +memberInfo: RelativeMemberInfo, + +memberInfo: + | LegacyRelativeMemberInfo + | MinimallyEncodedRelativeMemberInfo, +threadInfo: ResolvedThreadInfo, +canEdit: boolean, +navigate: ThreadSettingsNavigate, @@ -1123,7 +1126,9 @@ const threadMembersChangeIsSaving = ( state: AppState, - threadMembers: $ReadOnlyArray, + threadMembers: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, ) => { for (const threadMember of threadMembers) { const removeUserLoadingStatus = createLoadingStatusSelector( diff --git a/native/roles/change-roles-screen.react.js b/native/roles/change-roles-screen.react.js --- a/native/roles/change-roles-screen.react.js +++ b/native/roles/change-roles-screen.react.js @@ -12,8 +12,11 @@ import { otherUsersButNoOtherAdmins } from 'lib/selectors/thread-selectors.js'; import { roleIsAdminRole } from 'lib/shared/thread-utils.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import { values } from 'lib/utils/objects.js'; import ChangeRolesHeaderRightButton from './change-roles-header-right-button.react.js'; @@ -26,7 +29,7 @@ export type ChangeRolesScreenParams = { +threadInfo: ThreadInfo, - +memberInfo: RelativeMemberInfo, + +memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +role: ?string, }; 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,10 +9,13 @@ type MediaType, } from 'lib/types/media-types.js'; import type { RawTextMessageInfo } from 'lib/types/messages/text.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { ChatMentionCandidates, - RelativeMemberInfo, + LegacyRelativeMemberInfo, } from 'lib/types/thread-types.js'; export type PendingMultimediaUpload = { @@ -47,7 +50,9 @@ export type TypeaheadState = { +canBeVisible: boolean, +keepUpdatingThreadMembers: boolean, - +frozenUserMentionsCandidates: $ReadOnlyArray, + +frozenUserMentionsCandidates: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, +frozenChatMentionsCandidates: ChatMentionCandidates, +moveChoiceUp: ?() => void, +moveChoiceDown: ?() => void, 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 @@ -4,8 +4,11 @@ import { useENSNames } from 'lib/hooks/ens-cache.js'; import { stringForUser } from 'lib/shared/user-utils.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import type { UserListItem } from 'lib/types/user-types.js'; import { useSelector } from '../../../../redux/redux-utils.js'; @@ -40,7 +43,11 @@ ); const filterOutParentMembersWithENSNames = React.useCallback( - (members: $ReadOnlyArray) => + ( + members: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, + ) => members .filter( user => @@ -61,7 +68,11 @@ ); const filterOutOtherMembersWithENSNames = React.useCallback( - (members: $ReadOnlyArray) => + ( + members: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, + ) => members .filter( user => diff --git a/web/modals/threads/members/change-member-role-modal.react.js b/web/modals/threads/members/change-member-role-modal.react.js --- a/web/modals/threads/members/change-member-role-modal.react.js +++ b/web/modals/threads/members/change-member-role-modal.react.js @@ -11,8 +11,11 @@ import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; import { otherUsersButNoOtherAdmins } from 'lib/selectors/thread-selectors.js'; import { roleIsAdminRole } from 'lib/shared/thread-utils.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { RelativeMemberInfo } from 'lib/types/thread-types'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types'; import { values } from 'lib/utils/objects.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; @@ -25,7 +28,7 @@ import UnsavedChangesModal from '../../unsaved-changes-modal.react.js'; type ChangeMemberRoleModalProps = { - +memberInfo: RelativeMemberInfo, + +memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +threadInfo: ThreadInfo, }; diff --git a/web/modals/threads/members/member.react.js b/web/modals/threads/members/member.react.js --- a/web/modals/threads/members/member.react.js +++ b/web/modals/threads/members/member.react.js @@ -11,8 +11,11 @@ } from 'lib/shared/thread-utils.js'; import { stringForUser } from 'lib/shared/user-utils.js'; import type { SetState } from 'lib/types/hook-types.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import { useRolesFromCommunityThreadInfo } from 'lib/utils/role-utils.js'; @@ -28,7 +31,7 @@ const commIconComponent = ; type Props = { - +memberInfo: RelativeMemberInfo, + +memberInfo: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, +threadInfo: ThreadInfo, +setOpenMenu: SetState, }; diff --git a/web/modals/threads/members/members-list.react.js b/web/modals/threads/members/members-list.react.js --- a/web/modals/threads/members/members-list.react.js +++ b/web/modals/threads/members/members-list.react.js @@ -7,15 +7,20 @@ import { useENSNames } from 'lib/hooks/ens-cache.js'; import { stringForUser } from 'lib/shared/user-utils.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import { type RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRelativeMemberInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import ThreadMember from './member.react.js'; import css from './members-modal.css'; type Props = { +threadInfo: ThreadInfo, - +threadMembers: $ReadOnlyArray, + +threadMembers: $ReadOnlyArray< + LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + >, }; function ThreadMembersList(props: Props): React.Node { @@ -40,14 +45,20 @@ .map(([letter, users]) => { const userList = users .sort((a, b) => stringForUser(a).localeCompare(stringForUser(b))) - .map((user: RelativeMemberInfo) => ( - - )); + .map( + ( + user: + | LegacyRelativeMemberInfo + | MinimallyEncodedRelativeMemberInfo, + ) => ( + + ), + ); const letterHeader = (
{letter.toUpperCase()} diff --git a/web/modals/threads/members/members-modal.react.js b/web/modals/threads/members/members-modal.react.js --- a/web/modals/threads/members/members-modal.react.js +++ b/web/modals/threads/members/members-modal.react.js @@ -9,8 +9,9 @@ roleIsAdminRole, threadHasPermission, } from 'lib/shared/thread-utils.js'; +import type { MinimallyEncodedRelativeMemberInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import { type RelativeMemberInfo } from 'lib/types/thread-types.js'; +import type { LegacyRelativeMemberInfo } from 'lib/types/thread-types.js'; import { useRolesFromCommunityThreadInfo } from 'lib/utils/role-utils.js'; import { AddMembersModal } from './add-members-modal.react.js'; @@ -55,8 +56,9 @@ const allMembers = React.useMemo( () => threadMembersNotFiltered.filter( - (member: RelativeMemberInfo) => - searchText.length === 0 || userIDs.includes(member.id), + ( + member: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + ) => searchText.length === 0 || userIDs.includes(member.id), ), [searchText.length, threadMembersNotFiltered, userIDs], ); @@ -64,8 +66,10 @@ const roles = useRolesFromCommunityThreadInfo(threadInfo, allMembers); const adminMembers = React.useMemo( () => - allMembers.filter((member: RelativeMemberInfo) => - roleIsAdminRole(roles.get(member.id)), + allMembers.filter( + ( + member: LegacyRelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, + ) => roleIsAdminRole(roles.get(member.id)), ), [allMembers, roles], );