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 @@ -934,6 +934,31 @@ return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, options); } +function useThreadFrozenDueToViewerBlock( + threadInfo: ThreadInfo, + communityThreadInfo: ?ThreadInfo, + viewerID: ?string, + userInfos: UserInfos, +): boolean { + const communityRootsMembersToRole = useCommunityRootMembersToRole( + communityThreadInfo ? [communityThreadInfo] : [], + ); + const memberToRole = communityRootsMembersToRole?.[communityThreadInfo?.id]; + + const memberHasAdminRole = threadMembersWithoutAddedAdmin(threadInfo).some( + m => roleIsAdminRole(memberToRole?.[m.id]), + ); + if (memberHasAdminRole) { + return false; + } + + const options: ThreadIsWithBlockedUserOnlyOptions = { + checkOnlyViewerBlock: true, + skipMemberAdminRoleCheck: true, + }; + return threadIsWithBlockedUserOnly(threadInfo, viewerID, userInfos, options); +} + const threadTypeDescriptions: { [ThreadType]: string } = { [threadTypes.COMMUNITY_OPEN_SUBTHREAD]: 'Anybody in the parent channel can see an open subchannel.', @@ -1626,6 +1651,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'; @@ -315,6 +315,7 @@ +typeaheadMatchedStrings: ?TypeaheadMatchedStrings, +currentUserIsVoiced: boolean, +currentUserCanJoin: boolean, + +threadFrozen: boolean, }; type State = { +text: string, @@ -701,12 +702,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 +1265,13 @@ community ? threadInfoSelector(state)[community] : null, ); + const threadFrozen = useThreadFrozenDueToViewerBlock( + props.threadInfo, + communityThreadInfo, + viewerID, + userInfos, + ); + const userMentionsCandidates = useUserMentionsCandidates( props.threadInfo, parentThreadInfo, @@ -1376,6 +1379,7 @@ typeaheadMatchedStrings={typeaheadMatchedStrings} currentUserIsVoiced={currentUserIsVoiced} currentUserCanJoin={currentUserCanJoin} + threadFrozen={threadFrozen} /> ); }