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 @@ -61,7 +61,7 @@ draftKeyFromThreadID, threadActualMembers, threadFrozenDueToViewerBlock, - threadHasPermission, + useThreadHasPermission, viewerIsMember, } from 'lib/shared/thread-utils.js'; import type { CalendarQuery } from 'lib/types/entry-types.js'; @@ -313,6 +313,8 @@ +setSelectionState: SetState, +suggestions: $ReadOnlyArray, +typeaheadMatchedStrings: ?TypeaheadMatchedStrings, + +currentUserIsVoiced: boolean, + +currentUserCanJoin: boolean, }; type State = { +text: string, @@ -611,7 +613,7 @@ } get shouldShowTextInput(): boolean { - if (threadHasPermission(this.props.threadInfo, threadPermissions.VOICED)) { + if (this.props.currentUserIsVoiced) { return true; } // If the thread is created by somebody else while the viewer is attempting @@ -629,14 +631,14 @@ render(): React.Node { const isMember = viewerIsMember(this.props.threadInfo); - const canJoin = threadHasPermission( - this.props.threadInfo, - threadPermissions.JOIN_THREAD, - ); let joinButton = null; const threadColor = `#${this.props.threadInfo.color}`; const isEditMode = this.isEditMode(); - if (!isMember && canJoin && !this.props.threadCreationInProgress) { + if ( + !isMember && + this.props.currentUserCanJoin && + !this.props.threadCreationInProgress + ) { let buttonContent; if (this.props.joinThreadLoadingStatus === 'loading') { buttonContent = ( @@ -718,7 +720,7 @@ You don’t have permission to send messages. ); - } else if (defaultMembersAreVoiced && canJoin) { + } else if (defaultMembersAreVoiced && this.props.currentUserCanJoin) { content = null; } else { content = ( @@ -1330,6 +1332,16 @@ [suggestedUsers, suggestedChats], ); + const currentUserIsVoiced = useThreadHasPermission( + props.threadInfo, + threadPermissions.VOICED, + ); + + const currentUserCanJoin = useThreadHasPermission( + props.threadInfo, + threadPermissions.JOIN_THREAD, + ); + return ( ); }