Page MenuHomePhorge

D12287.1767177165.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D12287.1767177165.diff

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
@@ -954,6 +954,50 @@
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 = React.useMemo(
+ () => communityRootsMembersToRole?.[communityThreadInfo?.id],
+ [communityRootsMembersToRole, communityThreadInfo?.id],
+ );
+
+ const memberHasAdminRole = React.useMemo(
+ () =>
+ threadMembersWithoutAddedAdmin(threadInfo).some(m =>
+ roleIsAdminRole(memberToRole?.[m.id]),
+ ),
+ [memberToRole, threadInfo],
+ );
+
+ 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 +1690,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}
/>
);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 31, 10:32 AM (13 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5873128
Default Alt Text
D12287.1767177165.diff (3 KB)

Event Timeline