forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {clearCache, createVideoThumbnail} from 'react-native-compressor'
2import Animated, {FadeIn} from 'react-native-reanimated'
3import {Image} from 'expo-image'
4import {type QueryClient, useQuery} from '@tanstack/react-query'
5
6import {atoms as a} from '#/alf'
7
8export const RQKEY = 'video-thumbnail'
9
10export function clearThumbnailCache(queryClient: QueryClient) {
11 clearCache().catch(() => {})
12 queryClient.resetQueries({queryKey: [RQKEY]})
13}
14
15export function VideoTranscodeBackdrop({uri}: {uri: string}) {
16 const {data: thumbnail} = useQuery({
17 queryKey: [RQKEY, uri],
18 queryFn: async () => {
19 return await createVideoThumbnail(uri)
20 },
21 })
22
23 return (
24 thumbnail && (
25 <Animated.View style={a.flex_1} entering={FadeIn}>
26 <Image
27 style={a.flex_1}
28 source={thumbnail.path}
29 cachePolicy="none"
30 accessibilityIgnoresInvertColors
31 blurRadius={15}
32 contentFit="cover"
33 />
34 </Animated.View>
35 )
36 )
37}