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 @@ -4,42 +4,12 @@ import { useSelector } from './redux-utils.js'; import { threadInfoSelector } from '../selectors/thread-selectors.js'; -import { - type UserSurfacedPermissionOption, - userSurfacedPermissions, - userSurfacedPermissionOptions, -} 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, @@ -119,7 +89,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 @@ -10,9 +10,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'; @@ -139,12 +139,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({