diff --git a/lib/hooks/child-threads.js b/lib/hooks/child-threads.js --- a/lib/hooks/child-threads.js +++ b/lib/hooks/child-threads.js @@ -14,11 +14,8 @@ import { childThreadInfos } from '../selectors/thread-selectors.js'; import { threadInChatList } from '../shared/thread-utils.js'; import threadWatcher from '../shared/thread-watcher.js'; -import type { - MinimallyEncodedThreadInfo, - MinimallyEncodedRawThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; -import type { ThreadInfo, LegacyRawThreadInfo } from '../types/thread-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { ThreadInfo, RawThreadInfo } from '../types/thread-types.js'; import { useDispatchActionPromise } from '../utils/action-utils.js'; import { useSelector } from '../utils/redux-utils.js'; @@ -44,14 +41,7 @@ }, [childThreads, predicate]); const filterSubchannels = React.useCallback( - ( - thread: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo - ), - ) => { + (thread: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo)) => { const candidateThreadID = thread?.id; if (!candidateThreadID) { return false; diff --git a/lib/hooks/search-threads.js b/lib/hooks/search-threads.js --- a/lib/hooks/search-threads.js +++ b/lib/hooks/search-threads.js @@ -10,14 +10,11 @@ import { sidebarInfoSelector } from '../selectors/thread-selectors.js'; import { threadIsChannel } from '../shared/thread-utils.js'; import type { SetState } from '../types/hook-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import type { SidebarInfo, ThreadInfo, - LegacyRawThreadInfo, + RawThreadInfo, } from '../types/thread-types.js'; import { useSelector } from '../utils/redux-utils.js'; @@ -107,14 +104,8 @@ threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): SearchThreadsResult { const filterFunc = React.useCallback( - ( - thread: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo - ), - ) => threadIsChannel(thread) && thread?.parentThreadID === threadInfo.id, + (thread: ?(ThreadInfo | MinimallyEncodedThreadInfo | RawThreadInfo)) => + threadIsChannel(thread) && thread?.parentThreadID === threadInfo.id, [threadInfo.id], ); const childThreadInfos = useFilteredChatListData(filterFunc); 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 @@ -35,15 +35,12 @@ type LocalMessageInfo, isComposableMessageType, } from '../types/message-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import type { BaseAppState } from '../types/redux-types.js'; import { threadTypes } from '../types/thread-types-enum.js'; import { type ThreadInfo, - type LegacyRawThreadInfo, + type RawThreadInfo, type SidebarInfo, maxReadSidebars, maxUnreadSidebars, @@ -232,12 +229,7 @@ function useFilteredChatListData( filterFunction: ( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo - ), + threadInfo: ?(ThreadInfo | MinimallyEncodedThreadInfo | RawThreadInfo), ) => boolean, ): $ReadOnlyArray { const threadInfos = useSelector(threadInfoSelector); @@ -264,12 +256,7 @@ messageInfos: { +[id: string]: ?MessageInfo }, sidebarInfos: { +[id: string]: $ReadOnlyArray }, filterFunction: ( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo - ), + threadInfo: ?(ThreadInfo | MinimallyEncodedThreadInfo | RawThreadInfo), ) => boolean, ): $ReadOnlyArray { return _flow( 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 @@ -12,13 +12,10 @@ defaultCalendarQuery, } from '../types/entry-types.js'; import type { CalendarFilter } from '../types/filter-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } 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 { LegacyRawThreadInfo, ThreadInfo } from '../types/thread-types.js'; +import type { RawThreadInfo, ThreadInfo } from '../types/thread-types.js'; import type { UserInfo } from '../types/user-types.js'; import { getConfig } from '../utils/config.js'; import { values } from '../utils/objects.js'; @@ -84,10 +81,7 @@ function useThreadSearchIndex( threadInfos: $ReadOnlyArray< - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, >, ): SearchIndex { const userInfos = useSelector(state => state.userStore.userInfos); diff --git a/lib/shared/avatar-utils.js b/lib/shared/avatar-utils.js --- a/lib/shared/avatar-utils.js +++ b/lib/shared/avatar-utils.js @@ -16,15 +16,9 @@ ResolvedClientAvatar, GenericUserInfoWithAvatar, } from '../types/avatar-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from '../types/thread-types-enum.js'; -import { - type LegacyRawThreadInfo, - type ThreadInfo, -} from '../types/thread-types.js'; +import type { ThreadInfo, RawThreadInfo } from '../types/thread-types.js'; import type { UserInfos } from '../types/user-types.js'; import { useSelector } from '../utils/redux-utils.js'; import { ashoatKeyserverID } from '../utils/validation-utils.js'; @@ -277,11 +271,7 @@ } function getUserAvatarForThread( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, viewerID: ?string, userInfos: UserInfos, ): ClientAvatar { @@ -307,11 +297,7 @@ } function getAvatarForThread( - thread: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + thread: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, containingThreadInfo: ?ThreadInfo | ?MinimallyEncodedThreadInfo, ): ClientAvatar { if (thread.avatar) { @@ -328,11 +314,7 @@ } function useAvatarForThread( - thread: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + thread: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ): ClientAvatar { const containingThreadID = thread.containingThreadID; const containingThreadInfo = useSelector(state => 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 @@ -41,11 +41,8 @@ RawReactionMessageInfo, ReactionMessageInfo, } from '../types/messages/reaction.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; -import type { LegacyRawThreadInfo, ThreadInfo } from '../types/thread-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; +import type { RawThreadInfo, ThreadInfo } from '../types/thread-types.js'; import type { UserInfos } from '../types/user-types.js'; import { extractKeyserverIDFromID } from '../utils/action-utils.js'; import { @@ -683,11 +680,7 @@ function isInvalidPinSourceForThread( messageInfo: RawMessageInfo | MessageInfo, - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ): boolean { const isValidPinSource = !isInvalidPinSource(messageInfo); const isFirstMessageInSidebar = threadInfo.sourceMessageID === messageInfo.id; 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 @@ -92,6 +92,7 @@ type ChangeThreadSettingsPayload, type UserProfileThreadInfo, type RelativeMemberInfo, + type RawThreadInfo, } from '../types/thread-types.js'; import { updateTypes } from '../types/update-types-enum.js'; import { type ClientUpdateInfo } from '../types/update-types.js'; @@ -121,12 +122,7 @@ import { pendingThreadIDRegex } from '../utils/validation-utils.js'; function threadHasPermission( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), permission: ThreadPermission, ): boolean { if (!threadInfo) { @@ -144,12 +140,7 @@ } function viewerIsMember( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return !!( threadInfo && @@ -159,24 +150,14 @@ } function threadIsInHome( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return !!(threadInfo && threadInfo.currentUser.subscription.home); } // Can have messages function threadInChatList( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return ( viewerIsMember(threadInfo) && @@ -185,56 +166,31 @@ } function threadIsTopLevel( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return threadInChatList(threadInfo) && threadIsChannel(threadInfo); } function threadIsChannel( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return !!(threadInfo && threadInfo.type !== threadTypes.SIDEBAR); } function threadIsSidebar( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return threadInfo?.type === threadTypes.SIDEBAR; } function threadInBackgroundChatList( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return threadInChatList(threadInfo) && !threadIsInHome(threadInfo); } function threadInHomeChatList( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return threadInChatList(threadInfo) && threadIsInHome(threadInfo); } @@ -242,12 +198,7 @@ // Can have Calendar entries, // does appear as a top-level entity in the thread list function threadInFilterList( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), ): boolean { return ( threadInChatList(threadInfo) && @@ -257,12 +208,7 @@ } function userIsMember( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo - ), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo), userID: string, ): boolean { if (!threadInfo) { @@ -292,11 +238,7 @@ } function threadMembersWithoutAddedAshoat< - T: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + T: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, >(threadInfo: T): $PropertyType { if (threadInfo.community !== genesis.id) { return threadInfo.members; @@ -313,11 +255,7 @@ } function threadOrParentThreadIsGroupChat( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ) { return threadMembersWithoutAddedAshoat(threadInfo).length > 2; } @@ -331,11 +269,7 @@ } function getSingleOtherUser( - threadInfo: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, viewerID: ?string, ): ?string { if (!viewerID) { @@ -1056,11 +990,7 @@ } function threadIsWithBlockedUserOnly( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, viewerID: ?string, userInfos: UserInfos, checkOnlyViewerBlock?: boolean, @@ -1092,11 +1022,7 @@ } function threadFrozenDueToBlock( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, viewerID: ?string, userInfos: UserInfos, ): boolean { @@ -1104,11 +1030,7 @@ } function threadFrozenDueToViewerBlock( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, viewerID: ?string, userInfos: UserInfos, ): boolean { @@ -1124,11 +1046,7 @@ function memberIsAdmin( memberInfo: RelativeMemberInfo | MemberInfo, - threadInfo: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, ): boolean { return !!( memberInfo.role && roleIsAdminRole(threadInfo.roles[memberInfo.role]) @@ -1152,10 +1070,9 @@ function threadHasAdminRole( threadInfo: ?( - | LegacyRawThreadInfo + | RawThreadInfo | ThreadInfo | ServerThreadInfo - | MinimallyEncodedRawThreadInfo | MinimallyEncodedThreadInfo ), ): boolean { @@ -1166,11 +1083,7 @@ } function threadOrParentThreadHasAdminRole( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ) { return ( threadMembersWithoutAddedAshoat(threadInfo).filter(member => @@ -1422,9 +1335,8 @@ function threadMemberHasPermission( threadInfo: | ServerThreadInfo - | LegacyRawThreadInfo + | RawThreadInfo | ThreadInfo - | MinimallyEncodedRawThreadInfo | MinimallyEncodedThreadInfo, memberID: string, permission: ThreadPermission, @@ -1508,9 +1420,8 @@ function getContainingThreadID( parentThreadInfo: | ?ServerThreadInfo - | LegacyRawThreadInfo + | RawThreadInfo | ThreadInfo - | MinimallyEncodedRawThreadInfo | MinimallyEncodedThreadInfo, threadType: ThreadType, ): ?string { @@ -1529,9 +1440,8 @@ function getCommunity( parentThreadInfo: | ?ServerThreadInfo - | LegacyRawThreadInfo + | RawThreadInfo | ThreadInfo - | MinimallyEncodedRawThreadInfo | MinimallyEncodedThreadInfo, ): ?string { if (!parentThreadInfo) { @@ -1755,11 +1665,7 @@ } function threadInfoInsideCommunity( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, communityID: string, ): boolean { return threadInfo.community === communityID || threadInfo.id === communityID; @@ -1837,11 +1743,7 @@ } function communityOrThreadNoun( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ): string { return threadTypeIsCommunityRoot(threadInfo.type) ? 'community' @@ -1849,11 +1751,7 @@ } function getThreadsToDeleteText( - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ): string { return `${ threadTypeIsCommunityRoot(threadInfo.type) diff --git a/lib/shared/user-utils.js b/lib/shared/user-utils.js --- a/lib/shared/user-utils.js +++ b/lib/shared/user-utils.js @@ -2,12 +2,9 @@ import { memberHasAdminPowers } from './thread-utils.js'; import { useENSNames } from '../hooks/ens-cache.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, + RawThreadInfo, ServerThreadInfo, ThreadInfo, } from '../types/thread-types.js'; @@ -39,10 +36,9 @@ function useKeyserverAdmin( community: | ThreadInfo - | LegacyRawThreadInfo + | RawThreadInfo | ServerThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + | MinimallyEncodedThreadInfo, ): ?UserInfo { const userInfos = useSelector(state => state.userStore.userInfos); // This hack only works as long as there is only one admin 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 @@ -16,6 +16,7 @@ } from './message-types.js'; import type { MinimallyEncodedMemberInfo, + MinimallyEncodedRawThreadInfo, MinimallyEncodedRelativeMemberInfo, MinimallyEncodedResolvedThreadInfo, MinimallyEncodedRoleInfo, @@ -142,6 +143,8 @@ pinnedCount: t.maybe(t.Number), }); +export type RawThreadInfo = LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo; + export type ThreadInfo = { +id: string, +type: ThreadType, 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 @@ -3,15 +3,14 @@ import { values } from './objects.js'; 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'; import type { - LegacyRawThreadInfo, ThreadInfo, ResolvedThreadInfo, + RawThreadInfo, } from '../types/thread-types.js'; type WritableCommunityDrawerItemData = { @@ -107,11 +106,7 @@ function filterThreadIDsBelongingToCommunity( communityID: string, threadInfosObj: { - +[id: string]: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + +[id: string]: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, }, ): $ReadOnlySet { const threadInfos = values(threadInfosObj); diff --git a/lib/utils/entity-text.js b/lib/utils/entity-text.js --- a/lib/utils/entity-text.js +++ b/lib/utils/entity-text.js @@ -9,19 +9,13 @@ import { useENSNames, type UseENSNamesOptions } from '../hooks/ens-cache.js'; import { threadNoun } from '../shared/thread-utils.js'; import { stringForUser } from '../shared/user-utils.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { type ThreadType, threadTypes, threadTypeValidator, } from '../types/thread-types-enum.js'; -import { - type LegacyRawThreadInfo, - type ThreadInfo, -} from '../types/thread-types.js'; +import type { ThreadInfo, RawThreadInfo } from '../types/thread-types.js'; import { basePluralize } from '../utils/text-utils.js'; export type UserEntity = { @@ -145,21 +139,13 @@ } | { +display?: 'shortName', - +threadInfo: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + +threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, +subchannel?: ?boolean, +possessive?: ?boolean, } | { +display: 'alwaysDisplayShortName', - +threadInfo: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + +threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, +possessive?: ?boolean, } | { diff --git a/lib/utils/toggle-pin-utils.js b/lib/utils/toggle-pin-utils.js --- a/lib/utils/toggle-pin-utils.js +++ b/lib/utils/toggle-pin-utils.js @@ -3,20 +3,13 @@ import { isInvalidPinSourceForThread } from '../shared/message-utils.js'; import { threadHasPermission } from '../shared/thread-utils.js'; import type { RawMessageInfo, MessageInfo } from '../types/message-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from '../types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from '../types/thread-permission-types.js'; -import type { LegacyRawThreadInfo, ThreadInfo } from '../types/thread-types.js'; +import type { RawThreadInfo, ThreadInfo } from '../types/thread-types.js'; function canToggleMessagePin( messageInfo: RawMessageInfo | MessageInfo, - threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, ): boolean { const isValidMessage = !isInvalidPinSourceForThread(messageInfo, threadInfo); const hasManagePinsPermission = threadHasPermission( 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,14 +6,8 @@ import { ActivityIndicator, TouchableOpacity, View } from 'react-native'; import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import { useNativeSetThreadAvatar, @@ -29,11 +23,7 @@ import { useStyles } from '../themes/colors.js'; type Props = { - +threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + +threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, +disabled?: boolean, }; function EditThreadAvatar(props: Props): React.Node { 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 @@ -9,15 +9,14 @@ import { getSingleOtherUser } from 'lib/shared/thread-utils.js'; 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'; import type { - LegacyRawThreadInfo, ThreadInfo, ResolvedThreadInfo, + RawThreadInfo, } from 'lib/types/thread-types.js'; import Avatar from './avatar.react.js'; @@ -25,10 +24,9 @@ type Props = { +threadInfo: - | LegacyRawThreadInfo + | RawThreadInfo | ThreadInfo | ResolvedThreadInfo - | MinimallyEncodedRawThreadInfo | MinimallyEncodedThreadInfo | MinimallyEncodedResolvedThreadInfo, +size: AvatarSize, diff --git a/native/chat/settings/emoji-thread-avatar-creation.react.js b/native/chat/settings/emoji-thread-avatar-creation.react.js --- a/native/chat/settings/emoji-thread-avatar-creation.react.js +++ b/native/chat/settings/emoji-thread-avatar-creation.react.js @@ -6,14 +6,8 @@ import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js'; import { savedEmojiAvatarSelectorForThread } from 'lib/selectors/thread-selectors.js'; import type { UpdateUserAvatarRequest } from 'lib/types/avatar-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import { useNativeSetThreadAvatar } from '../../avatars/avatar-hooks.js'; import EmojiAvatarCreation from '../../avatars/emoji-avatar-creation.react.js'; @@ -23,11 +17,7 @@ import { useSelector } from '../../redux/redux-utils.js'; export type EmojiThreadAvatarCreationParams = { - +threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + +threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, }; type Props = { diff --git a/web/avatars/edit-thread-avatar-menu.react.js b/web/avatars/edit-thread-avatar-menu.react.js --- a/web/avatars/edit-thread-avatar-menu.react.js +++ b/web/avatars/edit-thread-avatar-menu.react.js @@ -6,14 +6,8 @@ import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js'; import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import { useUploadAvatarMedia } from './avatar-hooks.react.js'; import css from './edit-avatar-menu.css'; @@ -29,11 +23,7 @@ ); type Props = { - +threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + +threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, }; function EditThreadAvatarMenu(props: Props): React.Node { const { threadInfo } = props; diff --git a/web/avatars/edit-thread-avatar.react.js b/web/avatars/edit-thread-avatar.react.js --- a/web/avatars/edit-thread-avatar.react.js +++ b/web/avatars/edit-thread-avatar.react.js @@ -5,26 +5,16 @@ import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js'; import { threadHasPermission } from 'lib/shared/thread-utils.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import EditThreadAvatarMenu from './edit-thread-avatar-menu.react.js'; import css from './edit-thread-avatar.css'; import ThreadAvatar from './thread-avatar.react.js'; type Props = { - +threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + +threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, +disabled?: boolean, }; function EditThreadAvatar(props: Props): React.Node { diff --git a/web/avatars/thread-avatar.react.js b/web/avatars/thread-avatar.react.js --- a/web/avatars/thread-avatar.react.js +++ b/web/avatars/thread-avatar.react.js @@ -8,25 +8,15 @@ } from 'lib/shared/avatar-utils.js'; import { getSingleOtherUser } from 'lib/shared/thread-utils.js'; import type { AvatarSize } from 'lib/types/avatar-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from 'lib/types/minimally-encoded-thread-permissions-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 LegacyRawThreadInfo, - type ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ThreadInfo, RawThreadInfo } from 'lib/types/thread-types.js'; import Avatar from './avatar.react.js'; import { useSelector } from '../redux/redux-utils.js'; type Props = { - +threadInfo: - | LegacyRawThreadInfo - | ThreadInfo - | MinimallyEncodedRawThreadInfo - | MinimallyEncodedThreadInfo, + +threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedThreadInfo, +size: AvatarSize, +showSpinner?: boolean, }; diff --git a/web/avatars/thread-emoji-avatar-selection-modal.react.js b/web/avatars/thread-emoji-avatar-selection-modal.react.js --- a/web/avatars/thread-emoji-avatar-selection-modal.react.js +++ b/web/avatars/thread-emoji-avatar-selection-modal.react.js @@ -12,23 +12,13 @@ ClientAvatar, ClientEmojiAvatar, } from 'lib/types/avatar-types.js'; -import type { - MinimallyEncodedRawThreadInfo, - MinimallyEncodedThreadInfo, -} from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import EmojiAvatarSelectionModal from './emoji-avatar-selection-modal.react.js'; type Props = { - +threadInfo: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedThreadInfo - | MinimallyEncodedRawThreadInfo, + +threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedThreadInfo, }; function ThreadEmojiAvatarSelectionModal(props: Props): React.Node {