Bluesky app fork with some witchin' additions 💫

Android lightbox minor perf improvement (#9274)

* minor perf improvement on android for lightbox

* Use correct `cachePolicy` when prefetching lightbox images (#9275)

* use `memory` cachePolicy when prefetching

* use `memory` cache policy on iOS lightbox images

authored by samuel.fm and committed by

GitHub feab782b ca505fbb

+16 -4
+4 -1
src/components/Post/Embed/ImageEmbed.tsx
··· 64 64 } 65 65 const onPressIn = (_: number) => { 66 66 InteractionManager.runAfterInteractions(() => { 67 - Image.prefetch(items.map(i => i.uri)) 67 + Image.prefetch( 68 + items.map(i => i.uri), 69 + 'memory', 70 + ) 68 71 }) 69 72 } 70 73
+1
src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx
··· 252 252 onLoad({width: e.source.width, height: e.source.height}) 253 253 } 254 254 } 255 + cachePolicy="memory" 255 256 /> 256 257 </Animated.View> 257 258 </Animated.View>
+11 -3
src/view/com/util/List.tsx
··· 39 39 sideBorders?: boolean 40 40 progressViewOffset?: number 41 41 } 42 - export type ListRef = React.MutableRefObject<FlatList_INTERNAL | null> 42 + export type ListRef = React.RefObject<FlatList_INTERNAL | null> 43 43 44 44 const SCROLLED_DOWN_LIMIT = 200 45 45 ··· 61 61 const isScrolledDown = useSharedValue(false) 62 62 const t = useTheme() 63 63 const dedupe = useDedupe(400) 64 - const {activeLightbox} = useLightbox() 64 + const scrollsToTop = useAllowScrollToTop() 65 65 66 66 function handleScrolledDownChange(didScrollDown: boolean) { 67 67 onScrolledDownChange?.(didScrollDown) ··· 168 168 contentOffset={contentOffset} 169 169 refreshControl={refreshControl} 170 170 onScroll={scrollHandler} 171 - scrollsToTop={!activeLightbox} 171 + scrollsToTop={scrollsToTop} 172 172 scrollEventThrottle={1} 173 173 style={style} 174 174 // @ts-expect-error FlatList_INTERNAL ref type is wrong -sfn ··· 181 181 182 182 List = memo(List) 183 183 export {List} 184 + 185 + // We only want to use this context value on iOS because the `scrollsToTop` prop is iOS-only 186 + // removing it saves us a re-render on Android 187 + const useAllowScrollToTop = isIOS ? useAllowScrollToTopIOS : () => undefined 188 + function useAllowScrollToTopIOS() { 189 + const {activeLightbox} = useLightbox() 190 + return !activeLightbox 191 + }