Commit f3972ef4 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by Diego Mello
Browse files

[FIX] Some issues on preview message (#1271)

parent 6fd722a0
...@@ -5,7 +5,7 @@ import { Text } from 'react-native'; ...@@ -5,7 +5,7 @@ import { Text } from 'react-native';
import styles from './styles'; import styles from './styles';
const AtMention = React.memo(({ const AtMention = React.memo(({
mention, mentions, username, navToRoomInfo, style = [] mention, mentions, username, navToRoomInfo, preview, style = []
}) => { }) => {
let mentionStyle = styles.mention; let mentionStyle = styles.mention;
if (mention === 'all' || mention === 'here') { if (mention === 'all' || mention === 'here') {
...@@ -33,8 +33,8 @@ const AtMention = React.memo(({ ...@@ -33,8 +33,8 @@ const AtMention = React.memo(({
return ( return (
<Text <Text
style={[mentionStyle, ...style]} style={[preview ? styles.text : mentionStyle, ...style]}
onPress={handlePress} onPress={preview ? undefined : handlePress}
> >
{`@${ mention }`} {`@${ mention }`}
</Text> </Text>
...@@ -46,6 +46,7 @@ AtMention.propTypes = { ...@@ -46,6 +46,7 @@ AtMention.propTypes = {
username: PropTypes.string, username: PropTypes.string,
navToRoomInfo: PropTypes.func, navToRoomInfo: PropTypes.func,
style: PropTypes.array, style: PropTypes.array,
preview: PropTypes.bool,
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]) mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
}; };
......
...@@ -5,7 +5,7 @@ import { Text } from 'react-native'; ...@@ -5,7 +5,7 @@ import { Text } from 'react-native';
import styles from './styles'; import styles from './styles';
const Hashtag = React.memo(({ const Hashtag = React.memo(({
hashtag, channels, navToRoomInfo, style = [] hashtag, channels, navToRoomInfo, preview, style = []
}) => { }) => {
const handlePress = () => { const handlePress = () => {
const index = channels.findIndex(channel => channel.name === hashtag); const index = channels.findIndex(channel => channel.name === hashtag);
...@@ -19,8 +19,8 @@ const Hashtag = React.memo(({ ...@@ -19,8 +19,8 @@ const Hashtag = React.memo(({
if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) { if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) {
return ( return (
<Text <Text
style={[styles.mention, ...style]} style={[preview ? styles.text : styles.mention, ...style]}
onPress={handlePress} onPress={preview ? undefined : handlePress}
> >
{`#${ hashtag }`} {`#${ hashtag }`}
</Text> </Text>
...@@ -33,6 +33,7 @@ Hashtag.propTypes = { ...@@ -33,6 +33,7 @@ Hashtag.propTypes = {
hashtag: PropTypes.string, hashtag: PropTypes.string,
navToRoomInfo: PropTypes.func, navToRoomInfo: PropTypes.func,
style: PropTypes.array, style: PropTypes.array,
preview: PropTypes.bool,
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]) channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
}; };
......
...@@ -6,7 +6,7 @@ import styles from './styles'; ...@@ -6,7 +6,7 @@ import styles from './styles';
import openLink from '../../utils/openLink'; import openLink from '../../utils/openLink';
const Link = React.memo(({ const Link = React.memo(({
children, link children, link, preview
}) => { }) => {
const handlePress = () => { const handlePress = () => {
if (!link) { if (!link) {
...@@ -20,7 +20,7 @@ const Link = React.memo(({ ...@@ -20,7 +20,7 @@ const Link = React.memo(({
// if you have a [](https://rocket.chat) render https://rocket.chat // if you have a [](https://rocket.chat) render https://rocket.chat
return ( return (
<Text <Text
onPress={handlePress} onPress={preview ? undefined : handlePress}
style={styles.link} style={styles.link}
> >
{ childLength !== 0 ? children : link } { childLength !== 0 ? children : link }
...@@ -30,7 +30,8 @@ const Link = React.memo(({ ...@@ -30,7 +30,8 @@ const Link = React.memo(({
Link.propTypes = { Link.propTypes = {
children: PropTypes.node, children: PropTypes.node,
link: PropTypes.string link: PropTypes.string,
preview: PropTypes.bool
}; };
export default Link; export default Link;
...@@ -180,19 +180,25 @@ export default class Markdown extends PureComponent { ...@@ -180,19 +180,25 @@ export default class Markdown extends PureComponent {
); );
}; };
renderLink = ({ children, href }) => ( renderLink = ({ children, href }) => {
<MarkdownLink link={href}> const { preview } = this.props;
{children} return (
</MarkdownLink> <MarkdownLink link={href} preview={preview}>
); {children}
</MarkdownLink>
);
}
renderHashtag = ({ hashtag }) => { renderHashtag = ({ hashtag }) => {
const { channels, navToRoomInfo, style } = this.props; const {
channels, navToRoomInfo, style, preview
} = this.props;
return ( return (
<MarkdownHashtag <MarkdownHashtag
hashtag={hashtag} hashtag={hashtag}
channels={channels} channels={channels}
navToRoomInfo={navToRoomInfo} navToRoomInfo={navToRoomInfo}
preview={preview}
style={style} style={style}
/> />
); );
...@@ -200,7 +206,7 @@ export default class Markdown extends PureComponent { ...@@ -200,7 +206,7 @@ export default class Markdown extends PureComponent {
renderAtMention = ({ mentionName }) => { renderAtMention = ({ mentionName }) => {
const { const {
username, mentions, navToRoomInfo, style username, mentions, navToRoomInfo, preview, style
} = this.props; } = this.props;
return ( return (
<MarkdownAtMention <MarkdownAtMention
...@@ -208,6 +214,7 @@ export default class Markdown extends PureComponent { ...@@ -208,6 +214,7 @@ export default class Markdown extends PureComponent {
mention={mentionName} mention={mentionName}
username={username} username={username}
navToRoomInfo={navToRoomInfo} navToRoomInfo={navToRoomInfo}
preview={preview}
style={style} style={style}
/> />
); );
...@@ -275,11 +282,17 @@ export default class Markdown extends PureComponent { ...@@ -275,11 +282,17 @@ export default class Markdown extends PureComponent {
); );
}; };
renderBlockQuote = ({ children }) => ( renderBlockQuote = ({ children }) => {
<MarkdownBlockQuote> const { preview } = this.props;
{children} if (preview) {
</MarkdownBlockQuote> return children;
); }
return (
<MarkdownBlockQuote>
{children}
</MarkdownBlockQuote>
);
}
renderTable = ({ children, numColumns }) => ( renderTable = ({ children, numColumns }) => (
<MarkdownTable numColumns={numColumns}> <MarkdownTable numColumns={numColumns}>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment