2020-12-13 14:04:25 +01:00
|
|
|
import TimelineActioned from '@components/Timelines/Timeline/Shared/Actioned'
|
|
|
|
import TimelineActions from '@components/Timelines/Timeline/Shared/Actions'
|
|
|
|
import TimelineAttachment from '@components/Timelines/Timeline/Shared/Attachment'
|
|
|
|
import TimelineAvatar from '@components/Timelines/Timeline/Shared/Avatar'
|
|
|
|
import TimelineCard from '@components/Timelines/Timeline/Shared/Card'
|
|
|
|
import TimelineContent from '@components/Timelines/Timeline/Shared/Content'
|
|
|
|
import TimelineHeaderDefault from '@components/Timelines/Timeline/Shared/HeaderDefault'
|
|
|
|
import TimelinePoll from '@components/Timelines/Timeline/Shared/Poll'
|
2020-12-30 14:33:33 +01:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
2021-01-07 19:13:09 +01:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
|
|
|
import { getLocalAccount } from '@utils/slices/instancesSlice'
|
2020-12-13 14:04:25 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2020-12-30 14:33:33 +01:00
|
|
|
import React, { useCallback } from 'react'
|
|
|
|
import { Pressable, StyleSheet, View } from 'react-native'
|
2020-12-20 17:53:24 +01:00
|
|
|
import { useSelector } from 'react-redux'
|
2020-10-29 14:52:28 +01:00
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
export interface Props {
|
2021-01-12 00:12:44 +01:00
|
|
|
item: Mastodon.Status & { isPinned?: boolean }
|
2021-01-07 19:13:09 +01:00
|
|
|
queryKey?: QueryKeyTimeline
|
2020-12-12 22:19:18 +01:00
|
|
|
highlighted?: boolean
|
2021-01-04 18:29:02 +01:00
|
|
|
disableDetails?: boolean
|
|
|
|
disableOnPress?: boolean
|
2020-10-31 21:04:46 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 00:07:32 +01:00
|
|
|
// When the poll is long
|
2020-12-12 22:19:18 +01:00
|
|
|
const TimelineDefault: React.FC<Props> = ({
|
|
|
|
item,
|
|
|
|
queryKey,
|
2021-01-04 18:29:02 +01:00
|
|
|
highlighted = false,
|
|
|
|
disableDetails = false,
|
|
|
|
disableOnPress = false
|
2020-12-12 22:19:18 +01:00
|
|
|
}) => {
|
2021-01-07 19:13:09 +01:00
|
|
|
const localAccount = useSelector(getLocalAccount)
|
2020-10-29 14:52:28 +01:00
|
|
|
const navigation = useNavigation()
|
|
|
|
|
2020-11-22 00:46:23 +01:00
|
|
|
let actualStatus = item.reblog ? item.reblog : item
|
2020-10-29 14:52:28 +01:00
|
|
|
|
2020-12-27 18:43:49 +01:00
|
|
|
const onPress = useCallback(
|
2020-11-28 17:07:30 +01:00
|
|
|
() =>
|
2021-01-04 18:29:02 +01:00
|
|
|
!disableOnPress &&
|
2020-12-19 18:21:37 +01:00
|
|
|
!highlighted &&
|
2020-12-18 00:00:45 +01:00
|
|
|
navigation.push('Screen-Shared-Toot', {
|
2020-12-12 12:49:29 +01:00
|
|
|
toot: actualStatus
|
2020-11-28 17:07:30 +01:00
|
|
|
}),
|
|
|
|
[]
|
|
|
|
)
|
2021-01-03 02:00:26 +01:00
|
|
|
|
2020-12-27 18:43:49 +01:00
|
|
|
return (
|
2020-12-28 16:54:19 +01:00
|
|
|
<Pressable style={styles.statusView} onPress={onPress}>
|
2020-12-27 18:43:49 +01:00
|
|
|
{item.reblog ? (
|
|
|
|
<TimelineActioned action='reblog' account={item.account} />
|
2021-01-11 21:36:57 +01:00
|
|
|
) : item.isPinned ? (
|
2020-12-27 18:43:49 +01:00
|
|
|
<TimelineActioned action='pinned' account={item.account} />
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
<View style={styles.header}>
|
|
|
|
<TimelineAvatar
|
2021-01-04 18:29:02 +01:00
|
|
|
queryKey={disableOnPress ? undefined : queryKey}
|
2020-12-27 18:43:49 +01:00
|
|
|
account={actualStatus.account}
|
|
|
|
/>
|
2021-01-04 10:50:24 +01:00
|
|
|
<TimelineHeaderDefault
|
2021-01-04 18:29:02 +01:00
|
|
|
queryKey={disableOnPress ? undefined : queryKey}
|
2020-12-27 18:43:49 +01:00
|
|
|
status={actualStatus}
|
2021-01-04 10:50:24 +01:00
|
|
|
/>
|
2020-12-27 18:43:49 +01:00
|
|
|
</View>
|
|
|
|
|
2020-12-12 22:19:18 +01:00
|
|
|
<View
|
2020-12-13 23:02:54 +01:00
|
|
|
style={{
|
|
|
|
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
|
|
|
paddingLeft: highlighted
|
|
|
|
? 0
|
2020-12-19 01:57:57 +01:00
|
|
|
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
2020-12-13 23:02:54 +01:00
|
|
|
}}
|
2020-12-12 22:19:18 +01:00
|
|
|
>
|
2020-12-03 01:28:56 +01:00
|
|
|
{actualStatus.content.length > 0 && (
|
2021-01-04 18:29:02 +01:00
|
|
|
<TimelineContent
|
|
|
|
status={actualStatus}
|
|
|
|
highlighted={highlighted}
|
|
|
|
disableDetails={disableDetails}
|
|
|
|
/>
|
2020-12-03 01:28:56 +01:00
|
|
|
)}
|
2021-01-11 21:36:57 +01:00
|
|
|
{queryKey && actualStatus.poll ? (
|
2020-12-19 18:21:37 +01:00
|
|
|
<TimelinePoll
|
|
|
|
queryKey={queryKey}
|
2021-01-11 21:36:57 +01:00
|
|
|
statusId={actualStatus.id}
|
2020-12-19 18:21:37 +01:00
|
|
|
poll={actualStatus.poll}
|
|
|
|
reblog={item.reblog ? true : false}
|
2021-01-07 19:13:09 +01:00
|
|
|
sameAccount={actualStatus.account.id === localAccount?.id}
|
2020-12-19 18:21:37 +01:00
|
|
|
/>
|
2021-01-11 21:36:57 +01:00
|
|
|
) : null}
|
2021-01-04 18:29:02 +01:00
|
|
|
{!disableDetails && actualStatus.media_attachments.length > 0 && (
|
2020-12-30 14:33:33 +01:00
|
|
|
<TimelineAttachment status={actualStatus} />
|
2020-11-28 17:07:30 +01:00
|
|
|
)}
|
2021-01-04 18:29:02 +01:00
|
|
|
{!disableDetails && actualStatus.card && (
|
|
|
|
<TimelineCard card={actualStatus.card} />
|
|
|
|
)}
|
2020-12-12 22:19:18 +01:00
|
|
|
</View>
|
2020-12-14 22:33:19 +01:00
|
|
|
|
2021-01-04 18:29:02 +01:00
|
|
|
{queryKey && !disableDetails && (
|
2020-12-14 22:33:19 +01:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
paddingLeft: highlighted
|
|
|
|
? 0
|
2020-12-19 01:57:57 +01:00
|
|
|
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
2020-12-14 22:33:19 +01:00
|
|
|
}}
|
|
|
|
>
|
2020-12-19 18:21:37 +01:00
|
|
|
<TimelineActions
|
|
|
|
queryKey={queryKey}
|
|
|
|
status={actualStatus}
|
|
|
|
reblog={item.reblog ? true : false}
|
|
|
|
/>
|
2020-12-14 22:33:19 +01:00
|
|
|
</View>
|
|
|
|
)}
|
2020-12-27 18:43:49 +01:00
|
|
|
</Pressable>
|
2020-12-03 01:28:56 +01:00
|
|
|
)
|
2020-10-29 14:52:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2020-11-04 22:26:38 +01:00
|
|
|
statusView: {
|
2020-12-01 00:44:28 +01:00
|
|
|
padding: StyleConstants.Spacing.Global.PagePadding,
|
2021-01-01 16:48:16 +01:00
|
|
|
paddingBottom: StyleConstants.Spacing.S
|
2020-10-29 14:52:28 +01:00
|
|
|
},
|
2020-12-12 22:19:18 +01:00
|
|
|
header: {
|
2020-10-29 14:52:28 +01:00
|
|
|
flex: 1,
|
2020-12-12 22:19:18 +01:00
|
|
|
width: '100%',
|
2020-12-13 01:24:25 +01:00
|
|
|
flexDirection: 'row'
|
2020-10-29 14:52:28 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-12-19 18:21:37 +01:00
|
|
|
export default TimelineDefault
|