diff --git a/src/components/Post/Embed/ImageEmbed.tsx b/src/components/Post/Embed/ImageEmbed.tsx index 4ed17230e5..700408bdb8 100644 --- a/src/components/Post/Embed/ImageEmbed.tsx +++ b/src/components/Post/Embed/ImageEmbed.tsx @@ -64,7 +64,10 @@ export function ImageEmbed({ } const onPressIn = (_: number) => { InteractionManager.runAfterInteractions(() => { - Image.prefetch(items.map(i => i.uri)) + Image.prefetch( + items.map(i => i.uri), + 'memory', + ) }) } diff --git a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx index 7379704283..44907c8075 100644 --- a/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx +++ b/src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx @@ -252,6 +252,7 @@ const ImageItem = ({ onLoad({width: e.source.width, height: e.source.height}) } } + cachePolicy="memory" /> diff --git a/src/view/com/util/List.tsx b/src/view/com/util/List.tsx index 9b35846076..3ad788c0fb 100644 --- a/src/view/com/util/List.tsx +++ b/src/view/com/util/List.tsx @@ -39,7 +39,7 @@ export type ListProps = Omit< sideBorders?: boolean progressViewOffset?: number } -export type ListRef = React.MutableRefObject +export type ListRef = React.RefObject const SCROLLED_DOWN_LIMIT = 200 @@ -61,7 +61,7 @@ let List = React.forwardRef( const isScrolledDown = useSharedValue(false) const t = useTheme() const dedupe = useDedupe(400) - const {activeLightbox} = useLightbox() + const scrollsToTop = useAllowScrollToTop() function handleScrolledDownChange(didScrollDown: boolean) { onScrolledDownChange?.(didScrollDown) @@ -168,7 +168,7 @@ let List = React.forwardRef( contentOffset={contentOffset} refreshControl={refreshControl} onScroll={scrollHandler} - scrollsToTop={!activeLightbox} + scrollsToTop={scrollsToTop} scrollEventThrottle={1} style={style} // @ts-expect-error FlatList_INTERNAL ref type is wrong -sfn @@ -181,3 +181,11 @@ List.displayName = 'List' List = memo(List) export {List} + +// We only want to use this context value on iOS because the `scrollsToTop` prop is iOS-only +// removing it saves us a re-render on Android +const useAllowScrollToTop = isIOS ? useAllowScrollToTopIOS : () => undefined +function useAllowScrollToTopIOS() { + const {activeLightbox} = useLightbox() + return !activeLightbox +}