diff --git a/native/chat/settings/delete-thread.react.js b/native/chat/settings/delete-thread.react.js --- a/native/chat/settings/delete-thread.react.js +++ b/native/chat/settings/delete-thread.react.js @@ -49,7 +49,7 @@ type Props = { ...BaseProps, // Redux state - +threadInfo: ?ThreadInfo, + +threadInfo: ThreadInfo, +loadingStatus: LoadingStatus, +activeTheme: ?GlobalTheme, +colors: Colors, @@ -65,14 +65,6 @@ mounted = false; passwordInput: ?React.ElementRef; - static getThreadInfo(props: Props): ThreadInfo { - const { threadInfo } = props; - if (threadInfo) { - return threadInfo; - } - return props.route.params.threadInfo; - } - componentDidMount() { this.mounted = true; } @@ -87,14 +79,6 @@ } } - componentDidUpdate(prevProps: Props) { - const oldReduxThreadInfo = prevProps.threadInfo; - const newReduxThreadInfo = this.props.threadInfo; - if (newReduxThreadInfo && newReduxThreadInfo !== oldReduxThreadInfo) { - this.props.navigation.setParams({ threadInfo: newReduxThreadInfo }); - } - } - render() { const buttonContent = this.props.loadingStatus === 'loading' ? ( @@ -102,7 +86,7 @@ ) : ( Delete chat ); - const threadInfo = DeleteThread.getThreadInfo(this.props); + const { threadInfo } = this.props; return ( = React.memo( function ConnectedDeleteThread(props: BaseProps) { const threadID = props.route.params.threadInfo.id; - const threadInfo = useSelector( + const reduxThreadInfo = useSelector( state => threadInfoSelector(state)[threadID], ); + const { setParams } = props.navigation; + React.useEffect(() => { + if (reduxThreadInfo) { + setParams({ threadInfo: reduxThreadInfo }); + } + }, [reduxThreadInfo, setParams]); + const threadInfo: ThreadInfo = + reduxThreadInfo ?? props.route.params.threadInfo; + const loadingStatus = useSelector(loadingStatusSelector); const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme);