[FIX] Some issues on preview message (#1271)
This commit is contained in:
parent
6fd722a0d8
commit
f3972ef49e
|
@ -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 (
|
||||
<Text
|
||||
style={[mentionStyle, ...style]}
|
||||
onPress={handlePress}
|
||||
style={[preview ? styles.text : mentionStyle, ...style]}
|
||||
onPress={preview ? undefined : handlePress}
|
||||
>
|
||||
{`@${ mention }`}
|
||||
</Text>
|
||||
|
@ -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])
|
||||
};
|
||||
|
||||
|
|
|
@ -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 (
|
||||
<Text
|
||||
style={[styles.mention, ...style]}
|
||||
onPress={handlePress}
|
||||
style={[preview ? styles.text : styles.mention, ...style]}
|
||||
onPress={preview ? undefined : handlePress}
|
||||
>
|
||||
{`#${ hashtag }`}
|
||||
</Text>
|
||||
|
@ -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])
|
||||
};
|
||||
|
||||
|
|
|
@ -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 (
|
||||
<Text
|
||||
onPress={handlePress}
|
||||
onPress={preview ? undefined : handlePress}
|
||||
style={styles.link}
|
||||
>
|
||||
{ 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;
|
||||
|
|
|
@ -180,19 +180,25 @@ export default class Markdown extends PureComponent {
|
|||
);
|
||||
};
|
||||
|
||||
renderLink = ({ children, href }) => (
|
||||
<MarkdownLink link={href}>
|
||||
renderLink = ({ children, href }) => {
|
||||
const { preview } = this.props;
|
||||
return (
|
||||
<MarkdownLink link={href} preview={preview}>
|
||||
{children}
|
||||
</MarkdownLink>
|
||||
);
|
||||
}
|
||||
|
||||
renderHashtag = ({ hashtag }) => {
|
||||
const { channels, navToRoomInfo, style } = this.props;
|
||||
const {
|
||||
channels, navToRoomInfo, style, preview
|
||||
} = this.props;
|
||||
return (
|
||||
<MarkdownHashtag
|
||||
hashtag={hashtag}
|
||||
channels={channels}
|
||||
navToRoomInfo={navToRoomInfo}
|
||||
preview={preview}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
|
@ -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 (
|
||||
<MarkdownAtMention
|
||||
|
@ -208,6 +214,7 @@ export default class Markdown extends PureComponent {
|
|||
mention={mentionName}
|
||||
username={username}
|
||||
navToRoomInfo={navToRoomInfo}
|
||||
preview={preview}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
|
@ -275,11 +282,17 @@ export default class Markdown extends PureComponent {
|
|||
);
|
||||
};
|
||||
|
||||
renderBlockQuote = ({ children }) => (
|
||||
renderBlockQuote = ({ children }) => {
|
||||
const { preview } = this.props;
|
||||
if (preview) {
|
||||
return children;
|
||||
}
|
||||
return (
|
||||
<MarkdownBlockQuote>
|
||||
{children}
|
||||
</MarkdownBlockQuote>
|
||||
);
|
||||
}
|
||||
|
||||
renderTable = ({ children, numColumns }) => (
|
||||
<MarkdownTable numColumns={numColumns}>
|
||||
|
|
Loading…
Reference in New Issue