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 @@ -6,23 +6,25 @@ tHexEncodedPermissionsBitmask, tHexEncodedRolePermission, } from './minimally-encoded-thread-permissions.js'; +import { clientAvatarValidator } from '../types/avatar-types.js'; import type { MinimallyEncodedMemberInfo, - RawThreadInfo, MinimallyEncodedRelativeMemberInfo, - ResolvedThreadInfo, MinimallyEncodedRoleInfo, MinimallyEncodedThreadCurrentUserInfo, + RawThreadInfo, + ResolvedThreadInfo, ThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; +import { threadTypeValidator } from '../types/thread-types-enum.js'; +import type { LegacyRawThreadInfo } from '../types/thread-types.js'; import { legacyMemberInfoValidator, legacyRawThreadInfoValidator, legacyRoleInfoValidator, threadCurrentUserInfoValidator, - legacyThreadInfoValidator, } from '../types/thread-types.js'; -import type { LegacyRawThreadInfo } from '../types/thread-types.js'; +import { threadEntityValidator } from '../utils/entity-text.js'; import { tBool, tID, tShape } from '../utils/validation-utils.js'; const minimallyEncodedRoleInfoValidator: TInterface = @@ -55,11 +57,24 @@ const minimallyEncodedThreadInfoValidator: TInterface = tShape({ - ...legacyThreadInfoValidator.meta.props, minimallyEncoded: tBool(true), + id: tID, + type: threadTypeValidator, + name: t.maybe(t.String), + uiName: t.union([t.String, threadEntityValidator]), + avatar: t.maybe(clientAvatarValidator), + description: t.maybe(t.String), + color: t.String, + creationTime: t.Number, + parentThreadID: t.maybe(tID), + containingThreadID: t.maybe(tID), + community: t.maybe(tID), members: t.list(minimallyEncodedRelativeMemberInfoValidator), roles: t.dict(tID, minimallyEncodedRoleInfoValidator), currentUser: minimallyEncodedThreadCurrentUserInfoValidator, + sourceMessageID: t.maybe(tID), + repliesCount: t.Number, + pinnedCount: t.maybe(t.Number), }); const resolvedThreadInfoValidator: TInterface = 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 @@ -3,12 +3,13 @@ import invariant from 'invariant'; import _mapValues from 'lodash/fp/mapValues.js'; +import type { ClientAvatar } from './avatar-types.js'; +import type { ThreadType } from './thread-types-enum.js'; import type { LegacyMemberInfo, LegacyRawThreadInfo, LegacyRelativeMemberInfo, LegacyRoleInfo, - LegacyThreadInfo, ThreadCurrentUserInfo, } from './thread-types.js'; import { @@ -17,6 +18,7 @@ threadPermissionsFromBitmaskHex, threadRolePermissionsBlobToBitmaskArray, } from '../permissions/minimally-encoded-thread-permissions.js'; +import type { ThreadEntity } from '../utils/entity-text.js'; export type MinimallyEncodedRoleInfo = $ReadOnly<{ ...LegacyRoleInfo, @@ -185,11 +187,24 @@ }; export type ThreadInfo = $ReadOnly<{ - ...LegacyThreadInfo, +minimallyEncoded: true, + +id: string, + +type: ThreadType, + +name: ?string, + +uiName: string | ThreadEntity, + +avatar?: ?ClientAvatar, + +description: ?string, + +color: string, // hex, without "#" or "0x" + +creationTime: number, // millisecond timestamp + +parentThreadID: ?string, + +containingThreadID: ?string, + +community: ?string, +members: $ReadOnlyArray, +roles: { +[id: string]: MinimallyEncodedRoleInfo }, +currentUser: MinimallyEncodedThreadCurrentUserInfo, + +sourceMessageID?: string, + +repliesCount: number, + +pinnedCount?: number, }>; export type ResolvedThreadInfo = $ReadOnly<{ 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,10 +16,10 @@ } from './message-types.js'; import type { MinimallyEncodedMemberInfo, - RawThreadInfo, MinimallyEncodedRelativeMemberInfo, - ResolvedThreadInfo, MinimallyEncodedRoleInfo, + RawThreadInfo, + ResolvedThreadInfo, ThreadInfo, } from './minimally-encoded-thread-permissions-types.js'; import { @@ -36,10 +36,7 @@ import { type ThreadType, threadTypeValidator } from './thread-types-enum.js'; import type { ClientUpdateInfo, ServerUpdateInfo } from './update-types.js'; import type { UserInfo, UserInfos } from './user-types.js'; -import { - type ThreadEntity, - threadEntityValidator, -} from '../utils/entity-text.js'; +import { type ThreadEntity } from '../utils/entity-text.js'; import { tID, tShape } from '../utils/validation-utils.js'; export type LegacyMemberInfo = { @@ -63,11 +60,6 @@ +username: ?string, +isViewer: boolean, }>; -const legacyRelativeMemberInfoValidator = tShape({ - ...legacyMemberInfoValidator.meta.props, - username: t.maybe(t.String), - isViewer: t.Boolean, -}); export type RelativeMemberInfo = | LegacyRelativeMemberInfo @@ -151,46 +143,6 @@ +[id: string]: RawThreadInfo, }; -export type LegacyThreadInfo = { - +id: string, - +type: ThreadType, - +name: ?string, - +uiName: string | ThreadEntity, - +avatar?: ?ClientAvatar, - +description: ?string, - +color: string, // hex, without "#" or "0x" - +creationTime: number, // millisecond timestamp - +parentThreadID: ?string, - +containingThreadID: ?string, - +community: ?string, - +members: $ReadOnlyArray, - +roles: { +[id: string]: LegacyRoleInfo }, - +currentUser: ThreadCurrentUserInfo, - +sourceMessageID?: string, - +repliesCount: number, - +pinnedCount?: number, -}; -export const legacyThreadInfoValidator: TInterface = - tShape({ - id: tID, - type: threadTypeValidator, - name: t.maybe(t.String), - uiName: t.union([t.String, threadEntityValidator]), - avatar: t.maybe(clientAvatarValidator), - description: t.maybe(t.String), - color: t.String, - creationTime: t.Number, - parentThreadID: t.maybe(tID), - containingThreadID: t.maybe(tID), - community: t.maybe(tID), - members: t.list(legacyRelativeMemberInfoValidator), - roles: t.dict(tID, legacyRoleInfoValidator), - currentUser: threadCurrentUserInfoValidator, - sourceMessageID: t.maybe(tID), - repliesCount: t.Number, - pinnedCount: t.maybe(t.Number), - }); - export type ServerMemberInfo = { +id: string, +role: ?string, diff --git a/web/types/nav-types.js b/web/types/nav-types.js --- a/web/types/nav-types.js +++ b/web/types/nav-types.js @@ -3,9 +3,9 @@ import type { TInterface } from 'tcomb'; import t from 'tcomb'; +import { minimallyEncodedThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { type BaseNavInfo } from 'lib/types/nav-types.js'; -import { legacyThreadInfoValidator } from 'lib/types/thread-types.js'; import { type AccountUserInfo, accountUserInfoValidator, @@ -51,7 +51,7 @@ endDate: t.String, tab: navigationTabValidator, activeChatThreadID: t.maybe(tID), - pendingThread: t.maybe(legacyThreadInfoValidator), + pendingThread: t.maybe(minimallyEncodedThreadInfoValidator), settingsSection: t.maybe(navigationSettingsSectionValidator), selectedUserList: t.maybe(t.list(accountUserInfoValidator)), chatMode: t.maybe(navigationChatModeValidator),