diff --git a/package.json b/package.json index d79390c6..d662ff5e 100644 --- a/package.json +++ b/package.json @@ -72,4 +72,4 @@ "typescript": "~4.0.0" }, "private": true -} +} \ No newline at end of file diff --git a/src/components/Timelines.tsx b/src/components/Timelines.tsx index 1f136b58..be2ae834 100644 --- a/src/components/Timelines.tsx +++ b/src/components/Timelines.tsx @@ -59,6 +59,21 @@ const Timelines: React.FC = ({ name, content }) => { ) } + const screenComponent = useCallback( + () => ( + null} + onIndexChange={index => setSegment(index)} + navigationState={{ index: segment, routes }} + initialLayout={{ width: Dimensions.get('window').width }} + /> + ), + [segment] + ) + return ( = ({ name, content }) => { }) }} > - {() => { - return ( - null} - onIndexChange={index => setSegment(index)} - initialLayout={{ width: Dimensions.get('window').width }} - lazy - swipeEnabled - swipeVelocityImpact={1} - /> - ) - }} + {screenComponent} {sharedScreens(Stack)} @@ -110,9 +111,6 @@ const Timelines: React.FC = ({ name, content }) => { const styles = StyleSheet.create({ segmentsContainer: { flexBasis: '60%' - }, - base: { - width: Dimensions.get('window').width } }) diff --git a/src/components/Timelines/Timeline.tsx b/src/components/Timelines/Timeline.tsx index 5d0125e2..fc8829b4 100644 --- a/src/components/Timelines/Timeline.tsx +++ b/src/components/Timelines/Timeline.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react' -import { StyleSheet } from 'react-native' +import { RefreshControl, StyleSheet } from 'react-native' import { InfiniteData, useInfiniteQuery } from 'react-query' import TimelineNotifications from '@components/Timelines/Timeline/Notifications' @@ -57,6 +57,9 @@ const Timeline: React.FC = ({ fetchNextPage, isFetchingNextPage } = useInfiniteQuery(queryKey, timelineFetch, { + select: data => { + return { ...data, pages: data.pages.filter(page => page.toots.length) } + }, getPreviousPageParam: firstPage => ({ direction: 'prev', id: firstPage.toots[0].id @@ -137,6 +140,15 @@ const Timeline: React.FC = ({ () => (!disableRefresh ? : null), [hasNextPage] ) + const flRefreshControl = useMemo( + () => ( + + ), + [isFetchingPreviousPage] + ) const onScrollToIndexFailed = useCallback(error => { const offset = error.averageItemLength * error.index flRef.current?.scrollToOffset({ offset }) @@ -152,14 +164,16 @@ const Timeline: React.FC = ({ return ( = ({ accountDispatch, id }) => { - const [routes] = useState([ + const routes: { key: App.Pages }[] = [ { key: 'Account_Default' }, { key: 'Account_All' }, { key: 'Account_Media' } - ]) - const singleScene = useCallback( - ({ route }) => , - [] - ) - const renderScene = SceneMap({ - Account_Default: singleScene, - Account_All: singleScene, - Account_Media: singleScene - }) + ] + + const renderScene = ({ + route + }: { + route: { + key: App.Pages + } + }) => { + console.log(route) + return + } return ( null} + initialLayout={{ width: Dimensions.get('window').width }} + navigationState={{ index: accountState.segmentedIndex, routes }} onIndexChange={index => accountDispatch({ type: 'segmentedIndex', payload: index }) } - initialLayout={{ width: Dimensions.get('window').width }} - lazy - swipeEnabled /> ) }