diff options
author | Eric Bailey <git@esb.lol> | 2023-08-15 14:53:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 12:53:03 -0700 |
commit | 331c50672855e0c8a830aa59c5c2ce8b51b60f0c (patch) | |
tree | 0963282aa261f3cd822a312596f96f14e3b0bd9e /src/view/com/util | |
parent | 77178844fd29e2b7b4637557c4068901da0ef4e8 (diff) | |
download | voidsky-331c50672855e0c8a830aa59c5c2ce8b51b60f0c.tar.zst |
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
Diffstat (limited to 'src/view/com/util')
-rw-r--r-- | src/view/com/util/post-embeds/index.tsx | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/view/com/util/post-embeds/index.tsx b/src/view/com/util/post-embeds/index.tsx index b1c1c6a2e..5d0090434 100644 --- a/src/view/com/util/post-embeds/index.tsx +++ b/src/view/com/util/post-embeds/index.tsx @@ -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)) }) } |