From f3972ef49e80aa551d4a91359b2d4ddb3854d4a5 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 4 Oct 2019 10:28:36 -0300 Subject: [PATCH] [FIX] Some issues on preview message (#1271) --- app/containers/markdown/AtMention.js | 7 +++--- app/containers/markdown/Hashtag.js | 7 +++--- app/containers/markdown/Link.js | 7 +++--- app/containers/markdown/index.js | 37 +++++++++++++++++++--------- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/app/containers/markdown/AtMention.js b/app/containers/markdown/AtMention.js index 5b5f0480..eae24821 100644 --- a/app/containers/markdown/AtMention.js +++ b/app/containers/markdown/AtMention.js @@ -5,7 +5,7 @@ import { Text } from 'react-native'; import styles from './styles'; const AtMention = React.memo(({ - mention, mentions, username, navToRoomInfo, style = [] + mention, mentions, username, navToRoomInfo, preview, style = [] }) => { let mentionStyle = styles.mention; if (mention === 'all' || mention === 'here') { @@ -33,8 +33,8 @@ const AtMention = React.memo(({ return ( {`@${ mention }`} @@ -46,6 +46,7 @@ AtMention.propTypes = { username: PropTypes.string, navToRoomInfo: PropTypes.func, style: PropTypes.array, + preview: PropTypes.bool, mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]) }; diff --git a/app/containers/markdown/Hashtag.js b/app/containers/markdown/Hashtag.js index 25bd9258..c0e6b93d 100644 --- a/app/containers/markdown/Hashtag.js +++ b/app/containers/markdown/Hashtag.js @@ -5,7 +5,7 @@ import { Text } from 'react-native'; import styles from './styles'; const Hashtag = React.memo(({ - hashtag, channels, navToRoomInfo, style = [] + hashtag, channels, navToRoomInfo, preview, style = [] }) => { const handlePress = () => { const index = channels.findIndex(channel => channel.name === hashtag); @@ -19,8 +19,8 @@ const Hashtag = React.memo(({ if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) { return ( {`#${ hashtag }`} @@ -33,6 +33,7 @@ Hashtag.propTypes = { hashtag: PropTypes.string, navToRoomInfo: PropTypes.func, style: PropTypes.array, + preview: PropTypes.bool, channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]) }; diff --git a/app/containers/markdown/Link.js b/app/containers/markdown/Link.js index 79b1486c..de7bd7c6 100644 --- a/app/containers/markdown/Link.js +++ b/app/containers/markdown/Link.js @@ -6,7 +6,7 @@ import styles from './styles'; import openLink from '../../utils/openLink'; const Link = React.memo(({ - children, link + children, link, preview }) => { const handlePress = () => { if (!link) { @@ -20,7 +20,7 @@ const Link = React.memo(({ // if you have a [](https://rocket.chat) render https://rocket.chat return ( { childLength !== 0 ? children : link } @@ -30,7 +30,8 @@ const Link = React.memo(({ Link.propTypes = { children: PropTypes.node, - link: PropTypes.string + link: PropTypes.string, + preview: PropTypes.bool }; export default Link; diff --git a/app/containers/markdown/index.js b/app/containers/markdown/index.js index 6b1b6064..4282f96b 100644 --- a/app/containers/markdown/index.js +++ b/app/containers/markdown/index.js @@ -180,19 +180,25 @@ export default class Markdown extends PureComponent { ); }; - renderLink = ({ children, href }) => ( - - {children} - - ); + renderLink = ({ children, href }) => { + const { preview } = this.props; + return ( + + {children} + + ); + } renderHashtag = ({ hashtag }) => { - const { channels, navToRoomInfo, style } = this.props; + const { + channels, navToRoomInfo, style, preview + } = this.props; return ( ); @@ -200,7 +206,7 @@ export default class Markdown extends PureComponent { renderAtMention = ({ mentionName }) => { const { - username, mentions, navToRoomInfo, style + username, mentions, navToRoomInfo, preview, style } = this.props; return ( ); @@ -275,11 +282,17 @@ export default class Markdown extends PureComponent { ); }; - renderBlockQuote = ({ children }) => ( - - {children} - - ); + renderBlockQuote = ({ children }) => { + const { preview } = this.props; + if (preview) { + return children; + } + return ( + + {children} + + ); + } renderTable = ({ children, numColumns }) => (