diff --git a/app/containers/message/Video.tsx b/app/containers/message/Video.tsx index add8e8ef8..54910d9e6 100644 --- a/app/containers/message/Video.tsx +++ b/app/containers/message/Video.tsx @@ -1,7 +1,6 @@ import React, { useContext, useEffect, useState } from 'react'; import { StyleProp, StyleSheet, TextStyle, View, Text } from 'react-native'; import { dequal } from 'dequal'; -import * as VideoThumbnails from 'expo-video-thumbnails'; import FastImage from 'react-native-fast-image'; import messageStyles from './styles'; @@ -18,17 +17,10 @@ import { IAttachment } from '../../definitions/IAttachment'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { useTheme } from '../../theme'; import { formatAttachmentUrl } from '../../lib/methods/helpers/formatAttachmentUrl'; -import { - cancelDownload, - downloadMediaFile, - isDownloadActive, - getMediaCache, - getFileInfoAsync -} from '../../lib/methods/handleMediaDownload'; +import { cancelDownload, downloadMediaFile, isDownloadActive, getMediaCache } from '../../lib/methods/handleMediaDownload'; import { fetchAutoDownloadEnabled } from '../../lib/methods/autoDownloadPreference'; import sharedStyles from '../../views/Styles'; import BlurComponent from './Components/BlurComponent'; -import { useUserPreferences } from '../../lib/methods'; const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])]; const isTypeSupported = (type: string) => SUPPORTED_TYPES.indexOf(type) !== -1; @@ -75,48 +67,19 @@ const CancelIndicator = () => { ); }; -const Thumbnail = ({ loading, video, cached }: { loading: boolean; video: string; cached: boolean }) => { - const [thumbnailImage, setThumbnailImage] = useUserPreferences(`thumbnail-${video}`, ''); - - useEffect(() => { - const generateThumbnail = async () => { - try { - const { uri } = await VideoThumbnails.getThumbnailAsync(video, { - time: 1 - }); - setThumbnailImage(uri); - } catch (e) { - // do nothing - } - }; - - const handleThumbnailSearch = async () => { - const file = await getFileInfoAsync(thumbnailImage); - if (!file.exists) { - generateThumbnail(); - } - }; - - if (!thumbnailImage) { - generateThumbnail(); - } else { - handleThumbnailSearch(); - } - }, []); - - return ( - <> - {thumbnailImage ? : null} - - {loading ? : null} - - ); -}; +// TODO: Wait backend send the thumbnailUrl as prop +const Thumbnail = ({ loading, thumbnailUrl, cached }: { loading: boolean; thumbnailUrl?: string; cached: boolean }) => ( + <> + {thumbnailUrl ? : null} + + {loading ? : null} + +); const Video = React.memo( ({ file, showAttachment, getCustomEmoji, style, isReply }: IMessageVideo) => { @@ -245,7 +208,7 @@ const Video = React.memo( style={[styles.button, messageStyles.mustWrapBlur, { backgroundColor: themes[theme].videoBackground }]} background={Touchable.Ripple(themes[theme].bannerBackground)} > - + );