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 @@ -1642,42 +1642,6 @@ ); } -function getAvailableThreadMemberActions( - memberInfo: RelativeMemberInfo, - threadInfo: ThreadInfo, - canEdit: ?boolean = true, -): $ReadOnlyArray<'change_role' | 'remove_user'> { - const role = memberInfo.role; - if (!canEdit || !role) { - return []; - } - - const canRemoveMembers = threadHasPermission( - threadInfo, - threadPermissions.REMOVE_MEMBERS, - ); - const canChangeRoles = threadHasPermission( - threadInfo, - threadPermissions.CHANGE_ROLE, - ); - - const result = []; - - if (canChangeRoles && memberInfo.username && threadHasAdminRole(threadInfo)) { - result.push('change_role'); - } - - if ( - canRemoveMembers && - !memberInfo.isViewer && - (canChangeRoles || roleIsDefaultRole(threadInfo.roles[role])) - ) { - result.push('remove_user'); - } - - return result; -} - function useAvailableThreadMemberActions( memberInfo: RelativeMemberInfo, threadInfo: ThreadInfo, @@ -2000,7 +1964,6 @@ getThreadListSearchResults, useThreadListSearch, removeMemberFromThread, - getAvailableThreadMemberActions, useAvailableThreadMemberActions, threadMembersWithoutAddedAdmin, patchThreadInfoToIncludeMentionedMembersOfParent, diff --git a/native/chat/settings/thread-settings-member.react.js b/native/chat/settings/thread-settings-member.react.js --- a/native/chat/settings/thread-settings-member.react.js +++ b/native/chat/settings/thread-settings-member.react.js @@ -16,7 +16,7 @@ } from 'lib/actions/thread-actions.js'; import { useENSNames } from 'lib/hooks/ens-cache.js'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js'; -import { getAvailableThreadMemberActions } from 'lib/shared/thread-utils.js'; +import { useAvailableThreadMemberActions } from 'lib/shared/thread-utils.js'; import { stringForUser } from 'lib/shared/user-utils.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; import type { @@ -111,6 +111,7 @@ // withOverlayContext +overlayContext: ?OverlayContextType, +navigateToUserProfileBottomSheet: (userID: string) => mixed, + +availableThreadMemberActions: $ReadOnlyArray<'change_role' | 'remove_user'>, }; class ThreadSettingsMember extends React.PureComponent { editButton: ?React.ElementRef; @@ -144,13 +145,7 @@ color={this.props.colors.panelForegroundSecondaryLabel} /> ); - } else if ( - getAvailableThreadMemberActions( - this.props.memberInfo, - this.props.threadInfo, - this.props.canEdit, - ).length !== 0 - ) { + } else if (this.props.availableThreadMemberActions.length !== 0) { editButton = ( ); });