From 97ae9bce137eadba71ab771fddf1bf5f39e7dd35 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 27 May 2020 14:07:43 -0300 Subject: [PATCH] CreateDiscussionView --- app/stacks/InsideStack.js | 9 +++-- app/views/CreateDiscussionView/index.js | 50 ++++++++++++------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/stacks/InsideStack.js b/app/stacks/InsideStack.js index dce630619..d637241c4 100644 --- a/app/stacks/InsideStack.js +++ b/app/stacks/InsideStack.js @@ -53,6 +53,7 @@ import AttachmentView from '../views/AttachmentView'; import ModalBlockView from '../views/ModalBlockView'; import JitsiMeetView from '../views/JitsiMeetView'; import StatusView from '../views/StatusView'; +import CreateDiscussionView from '../views/CreateDiscussionView'; // ChatsStack const Chats = createStackNavigator(); @@ -100,7 +101,6 @@ const ChatsStack = () => { { SelectedUsersView.navigationOptions({ ...props })} /> + ); }; @@ -278,12 +281,10 @@ const InsideStackModal = () => { { - const submit = route.params?.submit ?? (() => {}); - const showSubmit = route.params?.showSubmit ?? route.params?.message; - return { - title: I18n.t('Create_Discussion'), - headerRight: ( - showSubmit - ? ( - - - - ) - : null - ), - headerLeft: - }; - } - propTypes = { navigation: PropTypes.object, + route: PropTypes.object, server: PropTypes.string, user: PropTypes.object, create: PropTypes.func, @@ -58,26 +41,26 @@ class CreateChannelView extends React.Component { constructor(props) { super(props); - const { navigation } = props; - navigation.setParams({ submit: this.submit }); - this.channel = navigation.getParam('channel'); - const message = navigation.getParam('message', {}); + const { route } = props; + this.channel = route.params?.channel; + const message = route.params?.message ?? {}; this.state = { channel: this.channel, message, - name: message.msg || '', + name: message?.msg || '', users: [], reply: '' }; + this.setHeader(); } componentDidUpdate(prevProps, prevState) { const { - loading, failure, error, result, navigation + loading, failure, error, result } = this.props; if (!isEqual(this.state, prevState)) { - navigation.setParams({ showSubmit: this.valid() }); + this.setHeader(); } if (!loading && loading !== prevProps.loading) { @@ -98,6 +81,23 @@ class CreateChannelView extends React.Component { } } + setHeader = () => { + const { navigation } = this.props; + navigation.setOptions({ + title: I18n.t('Create_Discussion'), + headerRight: ( + this.valid() + ? () => ( + + + + ) + : null + ), + headerLeft: () => + }); + } + submit = () => { const { name: t_name, channel: { prid, rid }, message: { id: pmid }, reply, users