From 507ecf5eeb26c4382522603b345a2458329b9e85 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sat, 3 Dec 2022 21:14:00 +0100 Subject: [PATCH] Fix history page --- src/components/Separator.tsx | 37 +++++---- src/screens/Tabs/Shared/History.tsx | 120 ++++++++++++++-------------- 2 files changed, 80 insertions(+), 77 deletions(-) diff --git a/src/components/Separator.tsx b/src/components/Separator.tsx index 0241ce90..b0d8802c 100644 --- a/src/components/Separator.tsx +++ b/src/components/Separator.tsx @@ -1,32 +1,35 @@ import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React from 'react' -import { StyleSheet, View } from 'react-native' +import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native' export interface Props { extraMarginLeft?: number extraMarginRight?: number + style?: StyleProp } -const ComponentSeparator = React.memo( - ({ extraMarginLeft = 0, extraMarginRight = 0 }: Props) => { - const { colors } = useTheme() +const ComponentSeparator: React.FC = ({ + extraMarginLeft = 0, + extraMarginRight = 0, + style +}) => { + const { colors } = useTheme() - return ( - - ) - }, - () => true -) + marginLeft: StyleConstants.Spacing.Global.PagePadding + extraMarginLeft, + marginRight: StyleConstants.Spacing.Global.PagePadding + extraMarginRight + } + ]} + /> + ) +} export default ComponentSeparator diff --git a/src/screens/Tabs/Shared/History.tsx b/src/screens/Tabs/Shared/History.tsx index ea8ef633..fc9a9d3c 100644 --- a/src/screens/Tabs/Shared/History.tsx +++ b/src/screens/Tabs/Shared/History.tsx @@ -5,6 +5,7 @@ import ComponentSeparator from '@components/Separator' import CustomText from '@components/Text' import TimelineAttachment from '@components/Timeline/Shared/Attachment' import TimelineContent from '@components/Timeline/Shared/Content' +import StatusContext from '@components/Timeline/Shared/Context' import HeaderSharedCreated from '@components/Timeline/Shared/HeaderShared/Created' import { TabSharedStackScreenProps } from '@utils/navigation/navigators' import { useStatusHistory } from '@utils/queryHooks/statusesHistory' @@ -12,58 +13,36 @@ import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' -import { View } from 'react-native' -import { ScrollView } from 'react-native-gesture-handler' +import { FlatList, View } from 'react-native' -const ContentView = ({ - history, - first, - last -}: { - history: Mastodon.StatusHistory - first: boolean - last: boolean -}) => { +const ContentView: React.FC<{ item: Mastodon.StatusHistory }> = ({ item }) => { const { colors } = useTheme() return ( - <> - - - {typeof history.content === 'string' && history.content.length > 0 ? ( - - ) : null} - {history.poll - ? history.poll.options.map((option, index) => ( - - - - - - - - - )) - : null} - {Array.isArray(history.media_attachments) && history.media_attachments.length ? ( - - ) : null} - - {!last ? : null} - + // @ts-ignore + + + + {item.poll?.options.map((option, index) => ( + + + + + + + + + ))} + + ) } @@ -84,19 +63,40 @@ const TabSharedHistory: React.FC }, []) return ( - - {data && data.length > 0 - ? data - .slice(0) - .reverse() - .map((d, i) => - i !== 0 ? ( - - ) : null - ) - : null} - + 0 + ? data + .slice(0) + .reverse() + .filter((_, index) => index !== 0) + : [] + } + renderItem={({ item }) => } + ItemSeparatorComponent={() => ( + + )} + /> ) + + // return ( + // + // {data && data.length > 0 + // ? data + // .slice(0) + // .reverse() + // .map((d, i) => + // i !== 0 ? ( + // + // ) : null + // ) + // : null} + // + // ) } export default TabSharedHistory