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 @@ -29,7 +29,6 @@ threadIsPending, threadMembersWithoutAddedAshoat, } from 'lib/shared/thread-utils'; -import { firstLine } from 'lib/utils/string-utils'; import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react'; import SWMansionIcon from '../components/swmansion-icon.react'; @@ -64,6 +63,7 @@ import ThreadSettings from './settings/thread-settings.react'; import ThreadScreenPruner from './thread-screen-pruner.react'; import ThreadSettingsButton from './thread-settings-button.react'; +import ThreadSettingsHeaderTitle from './thread-settings-header-title.react'; const unboundStyles = { keyboardAvoidingView: { @@ -240,7 +240,13 @@ headerBackTitleVisible: false, }; const threadSettingsOptions = ({ route }) => ({ - headerTitle: firstLine(route.params.threadInfo.uiName), + // eslint-disable-next-line react/display-name + headerTitle: props => ( + + ), headerBackTitleVisible: false, }); const deleteThreadOptions = { diff --git a/native/chat/thread-settings-header-title.react.js b/native/chat/thread-settings-header-title.react.js new file mode 100644 --- /dev/null +++ b/native/chat/thread-settings-header-title.react.js @@ -0,0 +1,27 @@ +// @flow + +import { + HeaderTitle, + type HeaderTitleInputProps, +} from '@react-navigation/elements'; +import * as React from 'react'; + +import type { ThreadInfo } from 'lib/types/thread-types'; +import { useResolvedThreadInfo } from 'lib/utils/entity-helpers'; +import { firstLine } from 'lib/utils/string-utils'; + +type Props = { + +threadInfo: ThreadInfo, + ...HeaderTitleInputProps, +}; +function ThreadSettingsHeaderTitle(props: Props): React.Node { + const { threadInfo, ...rest } = props; + const { uiName } = useResolvedThreadInfo(threadInfo); + return {firstLine(uiName)}; +} + +const MemoizedThreadSettingsHeaderTitle: React.ComponentType = React.memo( + ThreadSettingsHeaderTitle, +); + +export default MemoizedThreadSettingsHeaderTitle;