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,10 +58,10 @@ type RobotextMessageInfo, } from '../types/message-types.js'; import type { - RelativeMemberInfo, MinimallyEncodedRoleInfo, MinimallyEncodedThreadCurrentUserInfo, RawThreadInfo, + RelativeMemberInfo, ThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { @@ -92,10 +92,10 @@ ChangeThreadSettingsPayload, ClientNewThreadRequest, LegacyRawThreadInfo, + LegacyRoleInfo, MemberInfo, MixedRawThreadInfos, NewThreadResult, - RoleInfo, ServerMemberInfo, ServerThreadInfo, UserProfileThreadInfo, @@ -1038,7 +1038,9 @@ return !!memberInfo.permissions[threadPermissions.CHANGE_ROLE]?.value; } -function roleIsAdminRole(roleInfo: ?RoleInfo): boolean { +function roleIsAdminRole( + roleInfo: ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo, +): 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 @@ -16,7 +16,6 @@ } from './message-types.js'; import type { MinimallyEncodedMemberInfo, - MinimallyEncodedRoleInfo, RawThreadInfo, ResolvedThreadInfo, ThreadInfo, @@ -68,8 +67,6 @@ 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 @@ -5,6 +5,7 @@ import { useSelector } from './redux-utils.js'; import { threadInfoSelector } from '../selectors/thread-selectors.js'; import type { + MinimallyEncodedRoleInfo, RelativeMemberInfo, ThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; @@ -13,7 +14,7 @@ type ThreadRolePermissionsBlob, type UserSurfacedPermission, } from '../types/thread-permission-types.js'; -import type { RoleInfo } from '../types/thread-types'; +import type { LegacyRoleInfo } from '../types/thread-types'; import { threadTypes } from '../types/thread-types-enum.js'; function constructRoleDeletionMessagePrompt( @@ -58,7 +59,7 @@ function useRolesFromCommunityThreadInfo( threadInfo: ThreadInfo, memberInfos: $ReadOnlyArray, -): $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 @@ -73,7 +74,10 @@ community ? threadInfoSelector(state)[community] : null, ); const topMostThreadInfo = communityThreadInfo || threadInfo; - const roleMap = new Map(); + const roleMap = new Map< + string, + ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo, + >(); if (topMostThreadInfo.type === threadTypes.GENESIS) { memberInfos.forEach(memberInfo =>