From 91ff6e48d5958b4d3bec7bc209d1aaabac7484f5 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 13 Apr 2020 10:56:57 -0300 Subject: [PATCH] [FIX] UIKit with only one block (#2022) * [FIX] Message with only one block * [FIX] Update headers Co-authored-by: Diego Mello --- app/containers/message/Blocks.js | 3 +-- app/views/ModalBlockView.js | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/containers/message/Blocks.js b/app/containers/message/Blocks.js index 76a5e273..ba74ebe2 100644 --- a/app/containers/message/Blocks.js +++ b/app/containers/message/Blocks.js @@ -6,8 +6,7 @@ const Blocks = React.memo(({ blocks, id: mid, rid, blockAction }) => { if (blocks && blocks.length > 0) { - const [, secondBlock] = blocks; - const { appId = '' } = secondBlock; + const appId = blocks[0]?.appId || ''; return React.createElement( messageBlockWithContext({ action: async({ actionId, value, blockId }) => { diff --git a/app/views/ModalBlockView.js b/app/views/ModalBlockView.js index e00c8493..3c6314e2 100644 --- a/app/views/ModalBlockView.js +++ b/app/views/ModalBlockView.js @@ -67,7 +67,7 @@ class ModalBlockView extends React.Component { return { title: textParser([title]), ...themedHeader(theme), - headerLeft: ( + headerLeft: close ? ( - ), - headerRight: ( + ) : null, + headerRight: submit ? ( - ) + ) : null }; } @@ -136,7 +136,7 @@ class ModalBlockView extends React.Component { const { navigation } = this.props; const oldData = prevProps.navigation.getParam('data', {}); const newData = navigation.getParam('data', {}); - if (!isEqual(oldData, newData)) { + if (oldData.viewId !== newData.viewId) { navigation.push('ModalBlockView', { data: newData }); } } @@ -148,12 +148,14 @@ class ModalBlockView extends React.Component { } handleUpdate = ({ type, ...data }) => { + const { navigation } = this.props; if ([MODAL_ACTIONS.ERRORS].includes(type)) { const { errors } = data; this.setState({ errors }); } else { this.setState({ data }); } + navigation.setParams({ data }); }; cancel = async({ closeModal }) => {