Skip to content
8 changes: 8 additions & 0 deletions __mocks__/bugsnag-react-native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class Client { }

export default {
bugsnag: () => '',
leaveBreadcrumb: () => '',
notify: () => '',
loggerConfig: () => ''
};
3 changes: 3 additions & 0 deletions __mocks__/react-native-firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
analytics: null
};
3 changes: 3 additions & 0 deletions __tests__/__snapshots__/Storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27460,6 +27460,7 @@ exports[`Storyshots Message list message 1`] = `
Support
</Text>
<Text
onLongPress={[Function]}
onPress={[Function]}
style={
Object {
Expand Down Expand Up @@ -27531,6 +27532,7 @@ exports[`Storyshots Message list message 1`] = `

</Text>
<Text
onLongPress={[Function]}
onPress={[Function]}
style={
Object {
Expand Down Expand Up @@ -27666,6 +27668,7 @@ exports[`Storyshots Message list message 1`] = `

</Text>
<Text
onLongPress={[Function]}
onPress={[Function]}
style={
Object {
Expand Down
10 changes: 9 additions & 1 deletion app/containers/markdown/Link.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
import { Text, Clipboard } from 'react-native';

import styles from './styles';
import { themes } from '../../constants/colors';
import openLink from '../../utils/openLink';
import { LISTENER } from '../Toast';
import EventEmitter from '../../utils/events';
import I18n from '../../i18n';

const Link = React.memo(({
children, link, preview, theme
Expand All @@ -17,11 +20,16 @@ const Link = React.memo(({
};

const childLength = React.Children.toArray(children).filter(o => o).length;
const onLongPress = () => {
Clipboard.setString(link);
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
};

// if you have a [](https://rocket.chat) render https://rocket.chat
return (
<Text
onPress={preview ? undefined : handlePress}
onLongPress={preview ? undefined : onLongPress}
style={
!preview
? { ...styles.link, color: themes[theme].actionTintColor }
Expand Down
13 changes: 12 additions & 1 deletion app/containers/message/Urls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import {
View, Text, StyleSheet, Clipboard
} from 'react-native';
import PropTypes from 'prop-types';
import FastImage from 'react-native-fast-image';
import Touchable from 'react-native-platform-touchable';
Expand All @@ -10,6 +12,9 @@ import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { withSplit } from '../../split';
import { LISTENER } from '../Toast';
import EventEmitter from '../../utils/events';
import I18n from '../../i18n';

const styles = StyleSheet.create({
button: {
Expand Down Expand Up @@ -82,9 +87,15 @@ const Url = React.memo(({

const onPress = () => openLink(url.url, theme);

const onLongPress = () => {
Clipboard.setString(url.url);
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
};

return (
<Touchable
onPress={onPress}
onLongPress={onLongPress}
style={[
styles.button,
index > 0 && styles.marginTop,
Expand Down