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 @@ -10,44 +10,16 @@ MinimallyEncodedThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { - type UserSurfacedPermissionOption, - userSurfacedPermissions, - userSurfacedPermissionOptions, configurableCommunityPermissions, type ThreadRolePermissionsBlob, type UserSurfacedPermission, } from '../types/thread-permission-types.js'; -import { type ThreadType, threadTypes } from '../types/thread-types-enum.js'; import type { ThreadInfo, RelativeMemberInfo, RoleInfo, -} from '../types/thread-types.js'; - -function useFilterPermissionOptionsByThreadType( - threadType: ThreadType, -): $ReadOnlySet { - // If the thread is a community announcement root, we want to allow - // the option to be voiced in the announcement channels. Otherwise, - // we want to remove that option from being configured since this will - // be guaranteed on the keyserver. - const shouldFilterVoicedInAnnouncementChannel = - threadType === threadTypes.COMMUNITY_ROOT; - - return React.useMemo(() => { - if (!shouldFilterVoicedInAnnouncementChannel) { - return userSurfacedPermissionOptions; - } - - return new Set( - [...userSurfacedPermissionOptions].filter( - option => - option.userSurfacedPermission !== - userSurfacedPermissions.VOICED_IN_ANNOUNCEMENT_CHANNELS, - ), - ); - }, [shouldFilterVoicedInAnnouncementChannel]); -} +} from '../types/thread-types'; +import { threadTypes } from '../types/thread-types-enum.js'; function constructRoleDeletionMessagePrompt( defaultRoleName: string, @@ -155,7 +127,6 @@ } export { - useFilterPermissionOptionsByThreadType, constructRoleDeletionMessagePrompt, useRoleDeletableAndEditableStatus, useRolesFromCommunityThreadInfo, diff --git a/native/roles/create-roles-screen.react.js b/native/roles/create-roles-screen.react.js --- a/native/roles/create-roles-screen.react.js +++ b/native/roles/create-roles-screen.react.js @@ -11,9 +11,9 @@ import { type UserSurfacedPermissionOption, type UserSurfacedPermission, + userSurfacedPermissionOptions, } from 'lib/types/thread-permission-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; -import { useFilterPermissionOptionsByThreadType } from 'lib/utils/role-utils.js'; import CreateRolesHeaderRightButton from './create-roles-header-right-button.react.js'; import type { RolesNavigationProp } from './roles-navigator.react.js'; @@ -140,12 +140,9 @@ ], ); - const filteredUserSurfacedPermissionOptions = - useFilterPermissionOptionsByThreadType(threadInfo.type); - const permissionsList = React.useMemo( () => - [...filteredUserSurfacedPermissionOptions].map(permission => ( + [...userSurfacedPermissionOptions].map(permission => ( onEnumValuePress(permission)} /> )), - [ - isUserSurfacedPermissionSelected, - filteredUserSurfacedPermissionOptions, - onEnumValuePress, - ], + [isUserSurfacedPermissionSelected, onEnumValuePress], ); const onChangeRoleNameInput = React.useCallback((roleName: string) => { diff --git a/web/roles/create-roles-modal.react.js b/web/roles/create-roles-modal.react.js --- a/web/roles/create-roles-modal.react.js +++ b/web/roles/create-roles-modal.react.js @@ -11,9 +11,10 @@ import { useModalContext } from 'lib/components/modal-provider.react.js'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; -import type { - UserSurfacedPermission, - UserSurfacedPermissionOption, +import { + type UserSurfacedPermission, + type UserSurfacedPermissionOption, + userSurfacedPermissionOptions, } from 'lib/types/thread-permission-types.js'; import type { ThreadInfo, @@ -21,7 +22,6 @@ } from 'lib/types/thread-types.js'; import { useDispatchActionPromise } from 'lib/utils/action-utils.js'; import { values } from 'lib/utils/objects.js'; -import { useFilterPermissionOptionsByThreadType } from 'lib/utils/role-utils.js'; import css from './create-roles-modal.css'; import Button, { buttonThemes } from '../components/button.react.js'; @@ -141,12 +141,9 @@ [], ); - const filteredUserSurfacedPermissionOptions = - useFilterPermissionOptionsByThreadType(threadInfo.type); - const permissionsList = React.useMemo( () => - [...filteredUserSurfacedPermissionOptions].map(permission => ( + [...userSurfacedPermissionOptions].map(permission => ( )), - [ - filteredUserSurfacedPermissionOptions, - isUserSurfacedPermissionSelected, - onEnumValuePress, - ], + [isUserSurfacedPermissionSelected, onEnumValuePress], ); const errorMessageClassNames = classNames({