diff --git a/native/chat/chat.react.js b/native/chat/chat.react.js --- a/native/chat/chat.react.js +++ b/native/chat/chat.react.js @@ -21,7 +21,10 @@ import { useSelector } from 'react-redux'; import { isLoggedIn } from 'lib/selectors/user-selectors'; -import { threadIsPending } from 'lib/shared/thread-utils'; +import { + threadIsPending, + threadMembersWithoutAddedAshoat, +} from 'lib/shared/thread-utils'; import { firstLine } from 'lib/utils/string-utils'; import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react'; @@ -192,33 +195,44 @@ headerBackTitleVisible: false, headerStyle: unboundStyles.threadListHeaderStyle, }); -const messageListOptions = ({ navigation, route }) => ({ - // This is a render prop, not a component - // eslint-disable-next-line react/display-name - headerTitle: () => ( - - ), - headerTitleContainerStyle: { - marginHorizontal: Platform.select({ ios: 80, default: 0 }), - flex: 1, - }, - headerRight: - Platform.OS === 'android' && !threadIsPending(route.params.threadInfo.id) - ? // This is a render prop, not a component - // eslint-disable-next-line react/display-name - () => ( - - ) - : undefined, - headerBackTitleVisible: false, -}); + +const messageListOptions = ({ navigation, route }) => { + const isSearchEmpty = + !!route.params.searching && + threadMembersWithoutAddedAshoat(route.params.threadInfo).length === 1; + + const areSettingsEnabled = + !threadIsPending(route.params.threadInfo.id) && !isSearchEmpty; + + return { + // This is a render prop, not a component + // eslint-disable-next-line react/display-name + headerTitle: () => ( + + ), + headerTitleContainerStyle: { + marginHorizontal: Platform.select({ ios: 80, default: 0 }), + flex: 1, + }, + headerRight: + Platform.OS === 'android' && areSettingsEnabled + ? // This is a render prop, not a component + // eslint-disable-next-line react/display-name + () => ( + + ) + : undefined, + headerBackTitleVisible: false, + }; +}; const composeThreadOptions = { headerTitle: 'Compose chat', headerBackTitleVisible: false, diff --git a/native/chat/message-list-header-title.react.js b/native/chat/message-list-header-title.react.js --- a/native/chat/message-list-header-title.react.js +++ b/native/chat/message-list-header-title.react.js @@ -5,10 +5,6 @@ import { View, Platform } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons'; -import { - threadIsPending, - threadMembersWithoutAddedAshoat, -} from 'lib/shared/thread-utils'; import type { ThreadInfo } from 'lib/types/thread-types'; import { firstLine } from 'lib/utils/string-utils'; @@ -19,8 +15,9 @@ type BaseProps = { +threadInfo: ThreadInfo, - +searching: boolean | void, +navigate: $PropertyType, 'navigate'>, + +isSearchEmpty: boolean, + +areSettingsEnabled: boolean, }; type Props = { ...BaseProps, @@ -28,13 +25,8 @@ }; class MessageListHeaderTitle extends React.PureComponent { render() { - const isSearchEmpty = - this.props.searching && - threadMembersWithoutAddedAshoat(this.props.threadInfo).length === 1; let icon, fakeIcon; - const areSettingsDisabled = - threadIsPending(this.props.threadInfo.id) || isSearchEmpty; - if (Platform.OS === 'ios' && !areSettingsDisabled) { + if (Platform.OS === 'ios' && this.props.areSettingsEnabled) { icon = ( ); } - const title = isSearchEmpty ? 'New Message' : this.props.threadInfo.uiName; + + const title = this.props.isSearchEmpty + ? 'New Message' + : this.props.threadInfo.uiName; + return (