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 @@ -15,7 +15,7 @@ import { threadInChatList } from '../shared/thread-utils.js'; import threadWatcher from '../shared/thread-watcher.js'; import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; -import type { LegacyRawThreadInfo, ThreadInfo } from '../types/thread-types.js'; +import type { ThreadInfo } from '../types/thread-types.js'; import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; import { useSelector } from '../utils/redux-utils.js'; @@ -41,13 +41,7 @@ }, [childThreads, predicate]); const filterSubchannels = React.useCallback( - ( - thread: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), - ) => { + (thread: ?(MinimallyEncodedRawThreadInfo | ThreadInfo)) => { 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 @@ -11,11 +11,7 @@ import { threadIsChannel } from '../shared/thread-utils.js'; import type { SetState } from '../types/hook-types.js'; import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; -import type { - SidebarInfo, - ThreadInfo, - LegacyRawThreadInfo, -} from '../types/thread-types.js'; +import type { SidebarInfo, ThreadInfo } from '../types/thread-types.js'; import { useSelector } from '../utils/redux-utils.js'; export type ThreadSearchState = { @@ -104,13 +100,8 @@ threadInfo: ThreadInfo, ): SearchThreadsResult { const filterFunc = React.useCallback( - ( - thread: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - ), - ) => threadIsChannel(thread) && thread?.parentThreadID === threadInfo.id, + (thread: ?(ThreadInfo | MinimallyEncodedRawThreadInfo)) => + threadIsChannel(thread) && thread?.parentThreadID === threadInfo.id, [threadInfo.id], ); const childThreadInfos = useFilteredChatListData(filterFunc); diff --git a/lib/reducers/integrity-reducer.js b/lib/reducers/integrity-reducer.js --- a/lib/reducers/integrity-reducer.js +++ b/lib/reducers/integrity-reducer.js @@ -13,14 +13,13 @@ import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import type { BaseAction } from '../types/redux-types.js'; import { fullStateSyncActionType } from '../types/socket-types.js'; -import type { LegacyRawThreadInfo } from '../types/thread-types.js'; import { hash } from '../utils/objects.js'; function reduceIntegrityStore( state: IntegrityStore, action: BaseAction, threadInfos: { - +[string]: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo, + +[string]: MinimallyEncodedRawThreadInfo, }, threadStoreOperations: $ReadOnlyArray, ): IntegrityStore { 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 @@ -43,7 +43,6 @@ type ThreadInfo, maxReadSidebars, maxUnreadSidebars, - type LegacyRawThreadInfo, } from '../types/thread-types.js'; import type { UserInfo, @@ -229,11 +228,7 @@ function useFilteredChatListData( filterFunction: ( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - ), + threadInfo: ?(ThreadInfo | MinimallyEncodedRawThreadInfo), ) => boolean, ): $ReadOnlyArray { const threadInfos = useSelector(threadInfoSelector); @@ -260,11 +255,7 @@ messageInfos: { +[id: string]: ?MessageInfo }, sidebarInfos: { +[id: string]: $ReadOnlyArray }, filterFunction: ( - threadInfo: ?( - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - ), + threadInfo: ?(ThreadInfo | MinimallyEncodedRawThreadInfo), ) => 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 @@ -15,11 +15,7 @@ import type { MinimallyEncodedRawThreadInfo } 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, - ThreadInfo, - LegacyRawThreadInfo, -} from '../types/thread-types'; +import type { RelativeMemberInfo, ThreadInfo } from '../types/thread-types'; import type { UserInfo } from '../types/user-types.js'; import { getConfig } from '../utils/config.js'; import { values } from '../utils/objects.js'; @@ -121,9 +117,7 @@ } function useThreadSearchIndex( - threadInfos: $ReadOnlyArray< - LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, - >, + threadInfos: $ReadOnlyArray, ): SearchIndex { const userInfos = useSelector(state => state.userStore.userInfos); const viewerID = useSelector( 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 @@ -52,7 +52,7 @@ RelativeMemberInfo, ThreadInfo, RawThreadInfos, - LegacyRawThreadInfo, + MinimallyEncodedRawThreadInfos, } from '../types/thread-types.js'; import { dateString, dateFromString } from '../utils/date-utils.js'; import { values } from '../utils/objects.js'; @@ -275,7 +275,7 @@ const unreadCount: (state: BaseAppState<>) => number = createSelector( (state: BaseAppState<>) => state.threadStore.threadInfos, - (threadInfos: RawThreadInfos): number => + (threadInfos: MinimallyEncodedRawThreadInfos): number => values(threadInfos).filter( threadInfo => threadInHomeChatList(threadInfo) && threadInfo.currentUser.unread, @@ -284,7 +284,7 @@ const unreadBackgroundCount: (state: BaseAppState<>) => number = createSelector( (state: BaseAppState<>) => state.threadStore.threadInfos, - (threadInfos: RawThreadInfos): number => + (threadInfos: MinimallyEncodedRawThreadInfos): number => values(threadInfos).filter( threadInfo => threadInBackgroundChatList(threadInfo) && threadInfo.currentUser.unread, @@ -296,7 +296,7 @@ ) => (BaseAppState<>) => number = (communityID: string) => createSelector( (state: BaseAppState<>) => state.threadStore.threadInfos, - (threadInfos: RawThreadInfos): number => + (threadInfos: MinimallyEncodedRawThreadInfos): number => Object.values(threadInfos).filter( threadInfo => threadInHomeChatList(threadInfo) && @@ -344,7 +344,7 @@ (state: BaseAppState<>) => state.threadStore.threadInfos[threadID], relativeMemberInfoSelectorForMembersOfThread(threadID), ( - threadInfo: ?LegacyRawThreadInfo | ?MinimallyEncodedRawThreadInfo, + threadInfo: ?MinimallyEncodedRawThreadInfo, members: $ReadOnlyArray, ): boolean => { if (!threadInfo) { 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 @@ -297,7 +297,7 @@ } function getAvatarForThread( - thread: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + thread: MinimallyEncodedRawThreadInfo | ThreadInfo, containingThreadInfo: ?ThreadInfo, ): ClientAvatar { if (thread.avatar) { @@ -314,7 +314,7 @@ } function useAvatarForThread( - thread: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + thread: MinimallyEncodedRawThreadInfo | ThreadInfo, ): ClientAvatar { const containingThreadID = thread.containingThreadID; const containingThreadInfo = useSelector(state => 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 @@ -163,11 +163,7 @@ } function threadIsInHome( - threadInfo: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), + threadInfo: ?(MinimallyEncodedRawThreadInfo | ThreadInfo), ): boolean { return !!(threadInfo && threadInfo.currentUser.subscription.home); } @@ -187,51 +183,31 @@ } function threadIsTopLevel( - threadInfo: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), + threadInfo: ?(MinimallyEncodedRawThreadInfo | ThreadInfo), ): boolean { return threadInChatList(threadInfo) && threadIsChannel(threadInfo); } function threadIsChannel( - threadInfo: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), + threadInfo: ?(MinimallyEncodedRawThreadInfo | ThreadInfo), ): boolean { return !!(threadInfo && threadInfo.type !== threadTypes.SIDEBAR); } function threadIsSidebar( - threadInfo: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), + threadInfo: ?(MinimallyEncodedRawThreadInfo | ThreadInfo), ): boolean { return threadInfo?.type === threadTypes.SIDEBAR; } function threadInBackgroundChatList( - threadInfo: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), + threadInfo: ?(MinimallyEncodedRawThreadInfo | ThreadInfo), ): boolean { return threadInChatList(threadInfo) && !threadIsInHome(threadInfo); } function threadInHomeChatList( - threadInfo: ?( - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - ), + threadInfo: ?(MinimallyEncodedRawThreadInfo | ThreadInfo), ): boolean { return threadInChatList(threadInfo) && threadIsInHome(threadInfo); } @@ -1105,7 +1081,7 @@ } function threadFrozenDueToViewerBlock( - threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, viewerID: ?string, userInfos: UserInfos, ): boolean { @@ -1121,7 +1097,7 @@ function memberIsAdmin( memberInfo: RelativeMemberInfo | MemberInfo, - threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, ): boolean { return !!( memberInfo.role && roleIsAdminRole(threadInfo.roles[memberInfo.role]) @@ -1705,7 +1681,7 @@ } function threadInfoInsideCommunity( - threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, communityID: string, ): boolean { return threadInfo.community === communityID || threadInfo.id === communityID; @@ -1788,7 +1764,7 @@ } function communityOrThreadNoun( - threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, ): string { return threadTypeIsCommunityRoot(threadInfo.type) ? 'community' @@ -1796,7 +1772,7 @@ } function getThreadsToDeleteText( - threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, ): 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 @@ -3,11 +3,7 @@ import { memberHasAdminPowers } from './thread-utils.js'; import { useENSNames } from '../hooks/ens-cache.js'; import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ServerThreadInfo, - ThreadInfo, -} from '../types/thread-types.js'; +import type { ServerThreadInfo, ThreadInfo } from '../types/thread-types.js'; import type { UserInfo } from '../types/user-types.js'; import { useSelector } from '../utils/redux-utils.js'; @@ -34,11 +30,7 @@ } function useKeyserverAdmin( - community: - | ThreadInfo - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ServerThreadInfo, + community: ThreadInfo | MinimallyEncodedRawThreadInfo | ServerThreadInfo, ): ?UserInfo { const userInfos = useSelector(state => state.userStore.userInfos); // This hack only works as long as there is only one admin 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 @@ -6,11 +6,7 @@ import { threadInFilterList, threadIsChannel } from '../shared/thread-utils.js'; import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { communitySubthreads } from '../types/thread-types-enum.js'; -import type { - LegacyRawThreadInfo, - ResolvedThreadInfo, - ThreadInfo, -} from '../types/thread-types.js'; +import type { ResolvedThreadInfo, ThreadInfo } from '../types/thread-types.js'; type WritableCommunityDrawerItemData = { threadInfo: ThreadInfo, @@ -105,10 +101,7 @@ function filterThreadIDsBelongingToCommunity( communityID: string, threadInfosObj: { - +[id: string]: - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo, + +[id: string]: MinimallyEncodedRawThreadInfo | ThreadInfo, }, ): $ReadOnlySet { const threadInfos = values(threadInfosObj); 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 @@ -7,10 +7,7 @@ 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 { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useNativeSetThreadAvatar, @@ -26,7 +23,7 @@ import { useStyles } from '../themes/colors.js'; type Props = { - +threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, +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 @@ -10,21 +10,13 @@ import type { AvatarSize } from 'lib/types/avatar-types.js'; import type { MinimallyEncodedRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; -import type { - LegacyRawThreadInfo, - ResolvedThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ResolvedThreadInfo, ThreadInfo } from 'lib/types/thread-types.js'; import Avatar from './avatar.react.js'; import { useSelector } from '../redux/redux-utils.js'; type Props = { - +threadInfo: - | LegacyRawThreadInfo - | MinimallyEncodedRawThreadInfo - | ThreadInfo - | ResolvedThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo | ResolvedThreadInfo, +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 @@ -7,10 +7,7 @@ import { savedEmojiAvatarSelectorForThread } from 'lib/selectors/thread-selectors.js'; import type { UpdateUserAvatarRequest } from 'lib/types/avatar-types.js'; import type { MinimallyEncodedRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useNativeSetThreadAvatar } from '../../avatars/avatar-hooks.js'; import EmojiAvatarCreation from '../../avatars/emoji-avatar-creation.react.js'; @@ -20,7 +17,7 @@ import { useSelector } from '../../redux/redux-utils.js'; export type EmojiThreadAvatarCreationParams = { - +threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, }; 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 @@ -7,10 +7,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; import type { MinimallyEncodedRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; import { useUploadAvatarMedia } from './avatar-hooks.react.js'; import css from './edit-avatar-menu.css'; @@ -26,7 +23,7 @@ ); type Props = { - +threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, }; 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 @@ -7,17 +7,14 @@ import { threadHasPermission } from 'lib/shared/thread-utils.js'; import type { MinimallyEncodedRawThreadInfo } 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 { 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 | MinimallyEncodedRawThreadInfo | ThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, +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 @@ -10,16 +10,13 @@ import type { AvatarSize } from 'lib/types/avatar-types.js'; import type { MinimallyEncodedRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; import Avatar from './avatar.react.js'; import { useSelector } from '../redux/redux-utils.js'; type Props = { - +threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, +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 @@ -13,15 +13,12 @@ ClientEmojiAvatar, } from 'lib/types/avatar-types.js'; import type { MinimallyEncodedRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import type { - LegacyRawThreadInfo, - ThreadInfo, -} from 'lib/types/thread-types.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; import EmojiAvatarSelectionModal from './emoji-avatar-selection-modal.react.js'; type Props = { - +threadInfo: LegacyRawThreadInfo | MinimallyEncodedRawThreadInfo | ThreadInfo, + +threadInfo: MinimallyEncodedRawThreadInfo | ThreadInfo, }; function ThreadEmojiAvatarSelectionModal(props: Props): React.Node { 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 @@ -15,7 +15,10 @@ ComposableMessageInfo, RobotextMessageInfo, } from 'lib/types/message-types.js'; -import type { RawThreadInfos, ThreadInfo } from 'lib/types/thread-types.js'; +import type { + MinimallyEncodedRawThreadInfos, + ThreadInfo, +} from 'lib/types/thread-types.js'; import { values } from 'lib/utils/objects.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; @@ -140,7 +143,10 @@ createSelector( (state: AppState) => state.threadStore.threadInfos, (state: AppState) => state.communityPickerStore.chat, - (threadInfos: RawThreadInfos, communityID: ?string): number => + ( + threadInfos: MinimallyEncodedRawThreadInfos, + communityID: ?string, + ): number => values(threadInfos).filter( threadInfo => threadInHomeChatList(threadInfo) &&