diff --git a/src/screens/ImageViewer/index.tsx b/src/screens/ImageViewer/index.tsx index 140df005..28d3e9f6 100644 --- a/src/screens/ImageViewer/index.tsx +++ b/src/screens/ImageViewer/index.tsx @@ -4,7 +4,7 @@ import { useActionSheet } from '@expo/react-native-action-sheet' import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles' import { RootStackScreenProps } from '@utils/navigation/navigators' import { useTheme } from '@utils/styles/ThemeManager' -import React, { useState } from 'react' +import React, { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { Dimensions, @@ -50,6 +50,13 @@ const ScreenImagesViewer = ({ const isZoomed = useSharedValue(false) + const onViewableItemsChanged = useCallback( + ({ viewableItems }: { viewableItems: ViewToken[] }) => { + setCurrentIndex(viewableItems[0]?.index || 0) + }, + [] + ) + return ( { + onActivated={() => { showActionSheetWithOptions( { options: [ @@ -207,9 +214,7 @@ const ScreenImagesViewer = ({ /> ) }} - onViewableItemsChanged={({ viewableItems }: { viewableItems: ViewToken[] }) => { - setCurrentIndex(viewableItems[0]?.index || 0) - }} + onViewableItemsChanged={onViewableItemsChanged} viewabilityConfig={{ itemVisiblePercentThreshold: 50 }} diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index 5d11abe6..c01e97a9 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -1,4 +1,6 @@ +import Button from '@components/Button' import { HeaderLeft } from '@components/Header' +import Icon from '@components/Icon' import ComponentSeparator from '@components/Separator' import CustomText from '@components/Text' import TimelineDefault from '@components/Timeline/Default' @@ -9,6 +11,7 @@ import { useTheme } from '@utils/styles/ThemeManager' import React, { useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' import { FlatList, View } from 'react-native' +import { Circle } from 'react-native-animated-spinkit' import { Path, Svg } from 'react-native-svg' const TabSharedToot: React.FC> = ({ @@ -18,11 +21,11 @@ const TabSharedToot: React.FC> = ({ } }) => { const { colors } = useTheme() - const { t } = useTranslation('screenTabs') + const { t } = useTranslation(['componentTimeline', 'screenTabs']) useEffect(() => { navigation.setOptions({ - title: t('shared.toot.name'), + title: t('screenTabs:shared.toot.name'), headerLeft: () => navigation.goBack()} /> }) }, []) @@ -31,19 +34,19 @@ const TabSharedToot: React.FC> = ({ const scrolled = useRef(false) const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Toot', toot: toot.id }] - const { data } = useTootQuery({ + const { data, status, refetch } = useTootQuery({ ...queryKey[1], options: { meta: { toot }, onSuccess: data => { - if (data.body.length < 1) { + if (data.pages[0].body.length < 1) { navigation.goBack() return } if (!scrolled.current) { scrolled.current = true - const pointer = data.body.findIndex(({ id }) => id === toot.id) + const pointer = data.pages[0].body.findIndex(({ id }) => id === toot.id) if (pointer < 1) return const length = flRef.current?.props.data?.length if (!length) return @@ -64,6 +67,54 @@ const TabSharedToot: React.FC> = ({ } }) + const empty = () => { + switch (status) { + case 'loading': + return + case 'error': + return ( + <> + + + {t('componentTimeline:empty.error.message')} + +