remove generate thumbnail
This commit is contained in:
parent
71ec9698c9
commit
7e81d41eec
|
@ -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,38 +67,10 @@ 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 (
|
||||
// TODO: Wait backend send the thumbnailUrl as prop
|
||||
const Thumbnail = ({ loading, thumbnailUrl, cached }: { loading: boolean; thumbnailUrl?: string; cached: boolean }) => (
|
||||
<>
|
||||
{thumbnailImage ? <FastImage style={styles.thumbnailImage} source={{ uri: thumbnailImage }} /> : null}
|
||||
{thumbnailUrl ? <FastImage style={styles.thumbnailImage} source={{ uri: thumbnailUrl }} /> : null}
|
||||
<BlurComponent
|
||||
iconName={cached ? 'play-filled' : 'arrow-down-circle'}
|
||||
loading={loading}
|
||||
|
@ -116,7 +80,6 @@ const Thumbnail = ({ loading, video, cached }: { loading: boolean; video: string
|
|||
{loading ? <CancelIndicator /> : 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)}
|
||||
>
|
||||
<Thumbnail loading={loading} video={video} cached={cached} />
|
||||
<Thumbnail loading={loading} cached={cached} />
|
||||
</Touchable>
|
||||
</>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue