From 6f414d38be713d28d9b0995f321d6c61bd583316 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Tue, 7 Jun 2022 23:01:59 +0200 Subject: [PATCH] Fixed #321 --- src/components/Timeline.tsx | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/components/Timeline.tsx b/src/components/Timeline.tsx index b18aec52..6908a321 100644 --- a/src/components/Timeline.tsx +++ b/src/components/Timeline.tsx @@ -5,18 +5,11 @@ import { getInstanceActive } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { RefObject, useCallback, useRef } from 'react' -import { - FlatList, - FlatListProps, - Platform, - RefreshControl, - StyleSheet -} from 'react-native' +import { FlatList, FlatListProps, Platform, RefreshControl } from 'react-native' import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated' -import { useQueryClient } from 'react-query' import { useSelector } from 'react-redux' import TimelineEmpty from './Timeline/Empty' import TimelineFooter from './Timeline/Footer' @@ -149,7 +142,6 @@ const Timeline: React.FC = ({ data={flattenData} initialNumToRender={6} maxToRenderPerBatch={3} - style={styles.flatList} onEndReached={onEndReached} onEndReachedThreshold={0.75} ListFooterComponent={ @@ -160,9 +152,13 @@ const Timeline: React.FC = ({ } ListEmptyComponent={} ItemSeparatorComponent={ItemSeparatorComponent} - maintainVisibleContentPosition={{ - minIndexForVisible: 0 - }} + maintainVisibleContentPosition={ + isFetching + ? { + minIndexForVisible: 0 + } + : undefined + } {...androidRefreshControl} {...customProps} /> @@ -170,10 +166,4 @@ const Timeline: React.FC = ({ ) } -const styles = StyleSheet.create({ - flatList: { - minHeight: '100%' - } -}) - export default Timeline