Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370218
D11914.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11914.diff
View Options
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<Props> {
editButton: ?React.ElementRef<typeof View>;
@@ -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 = (
<TouchableOpacity
onPress={this.onPressEdit}
@@ -232,11 +227,7 @@
presentedFrom: this.props.threadSettingsRouteKey,
initialCoordinates: coordinates,
verticalBounds,
- visibleEntryIDs: getAvailableThreadMemberActions(
- this.props.memberInfo,
- this.props.threadInfo,
- this.props.canEdit,
- ),
+ visibleEntryIDs: this.props.availableThreadMemberActions,
memberInfo: this.props.memberInfo,
threadInfo: this.props.threadInfo,
},
@@ -283,6 +274,12 @@
]);
const roleName = roles.get(props.memberInfo.id)?.name;
+ const availableThreadMemberActions = useAvailableThreadMemberActions(
+ props.memberInfo,
+ props.threadInfo,
+ props.canEdit,
+ );
+
return (
<ThreadSettingsMember
{...props}
@@ -295,6 +292,7 @@
keyboardState={keyboardState}
overlayContext={overlayContext}
navigateToUserProfileBottomSheet={navigateToUserProfileBottomSheet}
+ availableThreadMemberActions={availableThreadMemberActions}
/>
);
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 1:27 AM (21 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587242
Default Alt Text
D11914.diff (3 KB)
Attached To
Mode
D11914: [native] Consume `useAvailableThreadMemberActions` in `native/ThreadSettingsMember`
Attached
Detach File
Event Timeline
Log In to Comment