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 @@ -61,7 +61,6 @@ MinimallyEncodedMemberInfo, MinimallyEncodedRawThreadInfo, MinimallyEncodedRelativeMemberInfo, - MinimallyEncodedRoleInfo, MinimallyEncodedThreadCurrentUserInfo, MinimallyEncodedThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; @@ -89,7 +88,7 @@ type ServerThreadInfo, type RelativeMemberInfo, type ThreadCurrentUserInfo, - type LegacyRoleInfo, + type RoleInfo, type ServerMemberInfo, type ClientNewThreadRequest, type NewThreadResult, @@ -1170,9 +1169,7 @@ return !!memberInfo.permissions[threadPermissions.CHANGE_ROLE]?.value; } -function roleIsAdminRole( - roleInfo: ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo, -): boolean { +function roleIsAdminRole(roleInfo: ?RoleInfo): boolean { return !!(roleInfo && !roleInfo.isDefault && roleInfo.name === 'Admins'); } 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 @@ -14,7 +14,10 @@ MessageTruncationStatuses, RawMessageInfo, } from './message-types.js'; -import type { MinimallyEncodedResolvedThreadInfo } from './minimally-encoded-thread-permissions-types.js'; +import type { + MinimallyEncodedResolvedThreadInfo, + MinimallyEncodedRoleInfo, +} from './minimally-encoded-thread-permissions-types.js'; import { type ThreadSubscription, threadSubscriptionValidator, @@ -73,6 +76,8 @@ isDefault: t.Boolean, }); +export type RoleInfo = LegacyRoleInfo | MinimallyEncodedRoleInfo; + export type ThreadCurrentUserInfo = { +role: ?string, +permissions: ThreadPermissionsInfo, 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 @@ -6,7 +6,6 @@ import { threadInfoSelector } from '../selectors/thread-selectors.js'; import type { MinimallyEncodedRelativeMemberInfo, - MinimallyEncodedRoleInfo, MinimallyEncodedThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { @@ -17,7 +16,7 @@ import type { ThreadInfo, RelativeMemberInfo, - LegacyRoleInfo, + RoleInfo, } from '../types/thread-types'; import { threadTypes } from '../types/thread-types-enum.js'; @@ -65,7 +64,7 @@ memberInfos: $ReadOnlyArray< RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo, >, -): $ReadOnlyMap { +): $ReadOnlyMap { // Our in-code system has chat-specific roles, while the // user-surfaced system has roles only for communities. We retrieve roles // from the top-level community thread for accuracy, with a rare fallback @@ -80,10 +79,7 @@ community ? threadInfoSelector(state)[community] : null, ); const topMostThreadInfo = communityThreadInfo || threadInfo; - const roleMap = new Map< - string, - ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo, - >(); + const roleMap = new Map(); if (topMostThreadInfo.type === threadTypes.GENESIS) { memberInfos.forEach(memberInfo =>