1- import { useCallback , useMemo , useState } from 'react' ;
1+ import { useMemo , useState } from 'react' ;
22import { RefreshControl , useWindowDimensions , View } from 'react-native' ;
33import { type PostData } from '@/src/common/lib/polycentric-hooks' ;
44import { Post } from './Post' ;
55import { useThread } from './hooks/useThread' ;
66import { Atoms } from '@/src/common/theme' ;
77import { ComposerInput } from '../composer' ;
88import { List , ListProps } from '@/src/common/components/List' ;
9+ import { isWeb } from '@/src/common/util/platform' ;
910
1011type ThreadListProps = Omit < ListProps < PostData > , 'data' | 'renderItem' > & {
1112 post : PostData ;
1213} ;
1314
1415export function ThreadList ( { post, ...rest } : ThreadListProps ) {
15- const [ refreshing , setRefreshing ] = useState ( false ) ;
1616 const { height : windowHeight } = useWindowDimensions ( ) ;
1717
18- const { thread } = useThread ( post ) ;
18+ const thread = useThread ( post ) ;
1919
2020 // Mount the subject by itself first.
2121 // Other items may or may not be available.
@@ -27,16 +27,11 @@ export function ThreadList({ post, ...rest }: ThreadListProps) {
2727
2828 const items = useMemo ( ( ) => {
2929 if ( ! isFirstLayoutComplete ) return [ post ] ;
30- return thread . length > 0 ? thread : [ post ] ;
31- } , [ isFirstLayoutComplete , thread , post ] ) ;
30+ return thread . items . length > 0 ? thread . items : [ post ] ;
31+ } , [ isFirstLayoutComplete , thread . items , post ] ) ;
3232
3333 const subjectIndex = items . findIndex ( ( p ) => p . id === post . id ) ;
3434
35- const handleRefresh = useCallback ( ( ) => {
36- setRefreshing ( true ) ;
37- setTimeout ( ( ) => setRefreshing ( false ) , 0 ) ;
38- } , [ ] ) ;
39-
4035 return (
4136 < List
4237 { ...rest }
@@ -67,7 +62,12 @@ export function ThreadList({ post, ...rest }: ThreadListProps) {
6762 } }
6863 ListFooterComponent = { < View style = { { height : windowHeight } } /> }
6964 refreshControl = {
70- < RefreshControl refreshing = { refreshing } onRefresh = { handleRefresh } />
65+ ! isWeb ? (
66+ < RefreshControl
67+ refreshing = { thread . isRefreshing }
68+ onRefresh = { thread . refresh }
69+ />
70+ ) : undefined
7171 }
7272 />
7373 ) ;
0 commit comments