fix video thumb cleanup (#6431)
This commit is contained in:
@@ -130,6 +130,7 @@ import {
|
|||||||
ThreadDraft,
|
ThreadDraft,
|
||||||
} from './state/composer'
|
} from './state/composer'
|
||||||
import {NO_VIDEO, NoVideoState, processVideo, VideoState} from './state/video'
|
import {NO_VIDEO, NoVideoState, processVideo, VideoState} from './state/video'
|
||||||
|
import {clearThumbnailCache} from './videos/VideoTranscodeBackdrop'
|
||||||
|
|
||||||
type CancelRef = {
|
type CancelRef = {
|
||||||
onPressCancel: () => void
|
onPressCancel: () => void
|
||||||
@@ -249,7 +250,8 @@ export const ComposePost = ({
|
|||||||
|
|
||||||
const onClose = useCallback(() => {
|
const onClose = useCallback(() => {
|
||||||
closeComposer()
|
closeComposer()
|
||||||
}, [closeComposer])
|
clearThumbnailCache(queryClient)
|
||||||
|
}, [closeComposer, queryClient])
|
||||||
|
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
const viewStyles = useMemo(
|
const viewStyles = useMemo(
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
import React, {useEffect} from 'react'
|
import React from 'react'
|
||||||
import {clearCache, createVideoThumbnail} from 'react-native-compressor'
|
import {clearCache, createVideoThumbnail} from 'react-native-compressor'
|
||||||
import Animated, {FadeIn} from 'react-native-reanimated'
|
import Animated, {FadeIn} from 'react-native-reanimated'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {useQuery} from '@tanstack/react-query'
|
import {QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
|
|
||||||
|
export const RQKEY = 'video-thumbnail'
|
||||||
|
|
||||||
|
export function clearThumbnailCache(queryClient: QueryClient) {
|
||||||
|
clearCache()
|
||||||
|
queryClient.resetQueries({queryKey: [RQKEY]})
|
||||||
|
}
|
||||||
|
|
||||||
export function VideoTranscodeBackdrop({uri}: {uri: string}) {
|
export function VideoTranscodeBackdrop({uri}: {uri: string}) {
|
||||||
const {data: thumbnail} = useQuery({
|
const {data: thumbnail} = useQuery({
|
||||||
queryKey: ['thumbnail', uri],
|
queryKey: [RQKEY, uri],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return await createVideoThumbnail(uri)
|
return await createVideoThumbnail(uri)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
return () => {
|
|
||||||
clearCache()
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
thumbnail && (
|
thumbnail && (
|
||||||
<Animated.View style={a.flex_1} entering={FadeIn}>
|
<Animated.View style={a.flex_1} entering={FadeIn}>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
export function clearThumbnailCache() {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
export function VideoTranscodeBackdrop() {
|
export function VideoTranscodeBackdrop() {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user