Bluesky app fork with some witchin' additions 💫

fix video thumb cleanup (#6431)

authored by samuel.fm and committed by

GitHub 8d1c93ef e9fe8d90

+17 -10
+3 -1
src/view/com/composer/Composer.tsx
··· 130 130 ThreadDraft, 131 131 } from './state/composer' 132 132 import {NO_VIDEO, NoVideoState, processVideo, VideoState} from './state/video' 133 + import {clearThumbnailCache} from './videos/VideoTranscodeBackdrop' 133 134 134 135 type CancelRef = { 135 136 onPressCancel: () => void ··· 249 250 250 251 const onClose = useCallback(() => { 251 252 closeComposer() 252 - }, [closeComposer]) 253 + clearThumbnailCache(queryClient) 254 + }, [closeComposer, queryClient]) 253 255 254 256 const insets = useSafeAreaInsets() 255 257 const viewStyles = useMemo(
+10 -9
src/view/com/composer/videos/VideoTranscodeBackdrop.tsx
··· 1 - import React, {useEffect} from 'react' 1 + import React from 'react' 2 2 import {clearCache, createVideoThumbnail} from 'react-native-compressor' 3 3 import Animated, {FadeIn} from 'react-native-reanimated' 4 4 import {Image} from 'expo-image' 5 - import {useQuery} from '@tanstack/react-query' 5 + import {QueryClient, useQuery} from '@tanstack/react-query' 6 6 7 7 import {atoms as a} from '#/alf' 8 8 9 + export const RQKEY = 'video-thumbnail' 10 + 11 + export function clearThumbnailCache(queryClient: QueryClient) { 12 + clearCache() 13 + queryClient.resetQueries({queryKey: [RQKEY]}) 14 + } 15 + 9 16 export function VideoTranscodeBackdrop({uri}: {uri: string}) { 10 17 const {data: thumbnail} = useQuery({ 11 - queryKey: ['thumbnail', uri], 18 + queryKey: [RQKEY, uri], 12 19 queryFn: async () => { 13 20 return await createVideoThumbnail(uri) 14 21 }, 15 22 }) 16 - 17 - useEffect(() => { 18 - return () => { 19 - clearCache() 20 - } 21 - }, []) 22 23 23 24 return ( 24 25 thumbnail && (
+4
src/view/com/composer/videos/VideoTranscodeBackdrop.web.tsx
··· 1 + export function clearThumbnailCache() { 2 + // no-op 3 + } 4 + 1 5 export function VideoTranscodeBackdrop() { 2 6 return null 3 7 }