Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3376781
D12287.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D12287.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
@@ -130,8 +130,12 @@
const communityThreadInfos = threadInfos.filter(threadInfo =>
threadTypeIsCommunityRoot(threadInfo.type),
);
- const communityRoots = _keyBy('id')(communityThreadInfos);
+ if (communityThreadInfos.length === 0) {
+ return {};
+ }
+
+ const communityRoots = _keyBy('id')(communityThreadInfos);
return _mapValues((threadInfo: ThreadInfo) => {
const keyedMembers = _keyBy('id')(threadInfo.members);
const keyedMembersToRole = _mapValues(
@@ -954,6 +958,43 @@
return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, options);
}
+function useThreadFrozenDueToViewerBlock(
+ threadInfo: ThreadInfo,
+ communityThreadInfo: ?ThreadInfo,
+ viewerID: ?string,
+ userInfos: UserInfos,
+): boolean {
+ const communityThreadInfoArray = React.useMemo(
+ () => (communityThreadInfo ? [communityThreadInfo] : []),
+ [communityThreadInfo],
+ );
+ const communityRootsMembersToRole = useCommunityRootMembersToRole(
+ communityThreadInfoArray,
+ );
+ const memberToRole = communityRootsMembersToRole[communityThreadInfo?.id];
+
+ const memberHasAdminRole = threadMembersWithoutAddedAdmin(threadInfo).some(
+ m => roleIsAdminRole(memberToRole?.[m.id]),
+ );
+
+ return React.useMemo(() => {
+ if (memberHasAdminRole) {
+ return false;
+ }
+
+ const options: ThreadIsWithBlockedUserOnlyOptions = {
+ checkOnlyViewerBlock: true,
+ skipMemberAdminRoleCheck: true,
+ };
+ return threadIsWithBlockedUserOnly(
+ threadInfo,
+ viewerID,
+ userInfos,
+ options,
+ );
+ }, [memberHasAdminRole, threadInfo, userInfos, viewerID]);
+}
+
const threadTypeDescriptions: { [ThreadType]: string } = {
[threadTypes.COMMUNITY_OPEN_SUBTHREAD]:
'Anybody in the parent channel can see an open subchannel.',
@@ -1646,6 +1687,7 @@
filterOutDisabledPermissions,
threadFrozenDueToBlock,
threadFrozenDueToViewerBlock,
+ useThreadFrozenDueToViewerBlock,
rawThreadInfoFromServerThreadInfo,
threadUIName,
threadInfoFromRawThreadInfo,
diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js
--- a/native/chat/chat-input-bar.react.js
+++ b/native/chat/chat-input-bar.react.js
@@ -60,7 +60,7 @@
checkIfDefaultMembersAreVoiced,
draftKeyFromThreadID,
threadActualMembers,
- threadFrozenDueToViewerBlock,
+ useThreadFrozenDueToViewerBlock,
useThreadHasPermission,
viewerIsMember,
} from 'lib/shared/thread-utils.js';
@@ -84,7 +84,6 @@
ClientThreadJoinRequest,
ThreadJoinPayload,
} from 'lib/types/thread-types.js';
-import { type UserInfos } from 'lib/types/user-types.js';
import {
type DispatchActionPromise,
useDispatchActionPromise,
@@ -284,7 +283,6 @@
+joinThreadLoadingStatus: LoadingStatus,
+threadCreationInProgress: boolean,
+calendarQuery: () => CalendarQuery,
- +userInfos: UserInfos,
+colors: Colors,
+styles: $ReadOnly<typeof unboundStyles>,
+onInputBarLayout?: (event: LayoutEvent) => mixed,
@@ -299,7 +297,6 @@
+chatMentionSearchIndex: ?SentencePrefixSearchIndex,
+chatMentionCandidates: ChatMentionCandidates,
+parentThreadInfo: ?ThreadInfo,
- +communityThreadInfo: ?ThreadInfo,
+editedMessagePreview: ?MessagePreviewResult,
+editedMessageInfo: ?MessageInfo,
+editMessage: (
@@ -315,6 +312,7 @@
+typeaheadMatchedStrings: ?TypeaheadMatchedStrings,
+currentUserIsVoiced: boolean,
+currentUserCanJoin: boolean,
+ +threadFrozen: boolean,
};
type State = {
+text: string,
@@ -701,12 +699,7 @@
if (this.shouldShowTextInput) {
content = this.renderInput();
} else if (
- threadFrozenDueToViewerBlock(
- this.props.threadInfo,
- this.props.communityThreadInfo,
- this.props.viewerID,
- this.props.userInfos,
- ) &&
+ this.props.threadFrozen &&
threadActualMembers(this.props.threadInfo.members).length === 2
) {
content = (
@@ -1269,6 +1262,13 @@
community ? threadInfoSelector(state)[community] : null,
);
+ const threadFrozen = useThreadFrozenDueToViewerBlock(
+ props.threadInfo,
+ communityThreadInfo,
+ viewerID,
+ userInfos,
+ );
+
const userMentionsCandidates = useUserMentionsCandidates(
props.threadInfo,
parentThreadInfo,
@@ -1350,7 +1350,6 @@
joinThreadLoadingStatus={joinThreadLoadingStatus}
threadCreationInProgress={threadCreationInProgress}
calendarQuery={calendarQuery}
- userInfos={userInfos}
colors={colors}
styles={styles}
isActive={isActive}
@@ -1363,7 +1362,6 @@
chatMentionSearchIndex={chatMentionSearchIndex}
chatMentionCandidates={chatMentionCandidates}
parentThreadInfo={parentThreadInfo}
- communityThreadInfo={communityThreadInfo}
editedMessagePreview={editedMessagePreview}
editedMessageInfo={editedMessageInfo}
editMessage={editMessage}
@@ -1376,6 +1374,7 @@
typeaheadMatchedStrings={typeaheadMatchedStrings}
currentUserIsVoiced={currentUserIsVoiced}
currentUserCanJoin={currentUserCanJoin}
+ threadFrozen={threadFrozen}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 2:07 AM (20 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592415
Default Alt Text
D12287.diff (5 KB)
Attached To
Mode
D12287: [lib] Introduce `useThreadFrozenDueToViewersBlock`
Attached
Detach File
Event Timeline
Log In to Comment