diff --git a/src/pages/home/report/LinkPreviewer.js b/src/pages/home/report/LinkPreviewer.js index ca5614fe2208..e8419a4d1c5d 100644 --- a/src/pages/home/report/LinkPreviewer.js +++ b/src/pages/home/report/LinkPreviewer.js @@ -1,9 +1,8 @@ -import React, {useState, useEffect} from 'react'; +import React from 'react'; import {View, Image} from 'react-native'; import PropTypes from 'prop-types'; import _ from 'underscore'; import {uniqBy} from 'lodash'; -import useWindowDimensions from '../../../hooks/useWindowDimensions'; import Text from '../../../components/Text'; import TextLink from '../../../components/TextLink'; import * as StyleUtils from '../../../styles/StyleUtils'; @@ -12,8 +11,8 @@ import variables from '../../../styles/variables'; import colors from '../../../styles/colors'; const IMAGE_TYPES = ['jpg', 'jpeg', 'png']; -const MAX_IMAGE_SIZE = 350; -const SMALL_SCREEN_MAX_IMAGE_SIZE = 180; +const MAX_IMAGE_HEIGHT = 180; +const MAX_IMAGE_WIDTH = 340; const propTypes = { /** Data about links provided in message. */ @@ -67,13 +66,6 @@ const defaultProps = { }; function LinkPreviewer(props) { - const {windowHeight} = useWindowDimensions(); - const [maxImageSize, setMaxImageSize] = useState(MAX_IMAGE_SIZE); - - useEffect(() => { - setMaxImageSize(windowHeight / 2 < MAX_IMAGE_SIZE ? SMALL_SCREEN_MAX_IMAGE_SIZE : MAX_IMAGE_SIZE); - }, [windowHeight]); - return _.map( _.take(uniqBy(props.linkMetadata, 'url'), props.maxAmountOfPreviews >= 0 ? Math.min(props.maxAmountOfPreviews, props.linkMetadata.length) : props.linkMetadata.length), (linkData) => { @@ -120,10 +112,10 @@ function LinkPreviewer(props) { styles.linkPreviewImage, { aspectRatio: image.width / image.height, - maxHeight: Math.min(image.height, maxImageSize), + maxHeight: Math.min(image.height, MAX_IMAGE_HEIGHT), // Calculate maximum width when image is too tall, so it doesn't move away from left - maxWidth: Math.min((Math.min(image.height, maxImageSize) / image.height) * image.width, maxImageSize), + maxWidth: Math.min((Math.min(image.height, MAX_IMAGE_HEIGHT) / image.height) * image.width, MAX_IMAGE_WIDTH), }, ]} resizeMode="contain"