Bluesky app fork with some witchin' additions 馃挮
at main 58 lines 1.6 kB view raw
1import React, {useCallback} from 'react' 2import {View} from 'react-native' 3import {msg} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {type FeedDescriptor} from '#/state/queries/post-feed' 7import {PostFeed} from '#/view/com/posts/PostFeed' 8import {EmptyState} from '#/view/com/util/EmptyState' 9import {type ListRef} from '#/view/com/util/List' 10import {type SectionRef} from '#/screens/Profile/Sections/types' 11import {HashtagWide_Stroke1_Corner0_Rounded as HashtagWideIcon} from '#/components/icons/Hashtag' 12import {IS_NATIVE} from '#/env' 13 14interface ProfilesListProps { 15 listUri: string 16 headerHeight: number 17 scrollElRef: ListRef 18} 19 20export const PostsList = React.forwardRef<SectionRef, ProfilesListProps>( 21 function PostsListImpl({listUri, headerHeight, scrollElRef}, ref) { 22 const feed: FeedDescriptor = `list|${listUri}` 23 const {_} = useLingui() 24 25 const onScrollToTop = useCallback(() => { 26 scrollElRef.current?.scrollToOffset({ 27 animated: IS_NATIVE, 28 offset: -headerHeight, 29 }) 30 }, [scrollElRef, headerHeight]) 31 32 React.useImperativeHandle(ref, () => ({ 33 scrollToTop: onScrollToTop, 34 })) 35 36 const renderPostsEmpty = useCallback(() => { 37 return ( 38 <EmptyState 39 icon={HashtagWideIcon} 40 iconSize="2xl" 41 message={_(msg`This feed is empty.`)} 42 /> 43 ) 44 }, [_]) 45 46 return ( 47 <View> 48 <PostFeed 49 feed={feed} 50 pollInterval={60e3} 51 scrollElRef={scrollElRef} 52 renderEmptyState={renderPostsEmpty} 53 headerOffset={headerHeight} 54 /> 55 </View> 56 ) 57 }, 58)