Skip to content
22 changes: 19 additions & 3 deletions app/containers/message/Urls.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import {
View,
Text,
StyleSheet,
Clipboard,
ToastAndroid,
Platform,
Vibration
} from 'react-native';
Comment on lines +2 to +4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included Clipboard, Vibrations, Platform modules of react-native which are not required by Url.js as they aren't required there. I included them for fixing the issue but you redirected me to our own Toast.js component, therefore, I removed the modules.
I'll revert them.

import PropTypes from 'prop-types';
import FastImage from 'react-native-fast-image';
import Touchable from 'react-native-platform-touchable';
import isEqual from 'lodash/isEqual';
Comment on lines 1 to 8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, undo all changes in this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they'll be undone


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo these changes.

import openLink from '../../utils/openLink';
import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors';
Expand Down Expand Up @@ -81,10 +88,19 @@ const Url = React.memo(({
}

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

Comment thread
djorkaeffalexandre marked this conversation as resolved.
const onLongPress = () => {
Clipboard.setString(url.url);
if (Platform.os === 'ios') {
Vibration.vibrate();
} else {
Vibration.vibrate(200);
ToastAndroid.show('Link copied', ToastAndroid.SHORT);
}
};
Comment on lines +91 to +93

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For first, you don't need to use ToastAndroid, we have our own Toast Component, you can search on our code how to use this.
I don't think you need to add some vibration when a link was copied, only the Toast is a feedback great.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thanks for the guidance. 👍

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