fix prefetching lightbox images (#1163)

* fix prefetching lightbox images

* use array signature

* fix other RN native image usage

* delay prefetching to allow UI to re-render
This commit is contained in:
Eric Bailey 2023-08-15 14:53:03 -05:00 committed by GitHub
parent 77178844fd
commit 331c506728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View file

@ -4,9 +4,10 @@ import {
StyleProp,
View,
ViewStyle,
Image as RNImage,
Text,
InteractionManager,
} from 'react-native'
import {Image} from 'expo-image'
import {
AppBskyEmbedImages,
AppBskyEmbedExternal,
@ -95,14 +96,9 @@ export function PostEmbeds({
const openLightbox = (index: number) => {
store.shell.openLightbox(new ImagesLightbox(items, index))
}
const onPressIn = (index: number) => {
const firstImageToShow = items[index].uri
RNImage.prefetch(firstImageToShow)
items.forEach(item => {
if (firstImageToShow !== item.uri) {
// First image already prefetched above
RNImage.prefetch(item.uri)
}
const onPressIn = (_: number) => {
InteractionManager.runAfterInteractions(() => {
Image.prefetch(items.map(i => i.uri))
})
}