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 TimelineHeaderNotification from '@components/Timelines/Timeline/Shared/HeaderNotification'
|
|
|
|
import TimelinePoll from '@components/Timelines/Timeline/Shared/Poll'
|
2020-12-30 14:33:33 +01:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
|
|
|
import { getLocalAccountId } 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-11-04 22:26:38 +01:00
|
|
|
|
|
|
|
export interface Props {
|
2020-11-21 00:40:55 +01:00
|
|
|
notification: Mastodon.Notification
|
2020-12-18 23:58:53 +01:00
|
|
|
queryKey: QueryKey.Timeline
|
2020-12-13 23:02:54 +01:00
|
|
|
highlighted?: boolean
|
2020-11-04 22:26:38 +01:00
|
|
|
}
|
|
|
|
|
2020-12-13 23:02:54 +01:00
|
|
|
const TimelineNotifications: React.FC<Props> = ({
|
|
|
|
notification,
|
|
|
|
queryKey,
|
|
|
|
highlighted = false
|
|
|
|
}) => {
|
2020-12-20 17:53:24 +01:00
|
|
|
const localAccountId = useSelector(getLocalAccountId)
|
2020-11-04 22:26:38 +01:00
|
|
|
const navigation = useNavigation()
|
2020-11-06 00:59:33 +01:00
|
|
|
const actualAccount = notification.status
|
|
|
|
? notification.status.account
|
|
|
|
: notification.account
|
2020-11-04 22:26:38 +01:00
|
|
|
|
2020-12-27 18:43:49 +01:00
|
|
|
const onPress = useCallback(
|
2020-12-12 18:22:22 +01:00
|
|
|
() =>
|
2021-01-04 10:50:24 +01:00
|
|
|
notification.status &&
|
2020-12-27 18:43:49 +01:00
|
|
|
navigation.push('Screen-Shared-Toot', {
|
2020-12-13 23:02:54 +01:00
|
|
|
toot: notification.status
|
2020-12-12 18:22:22 +01:00
|
|
|
}),
|
|
|
|
[]
|
|
|
|
)
|
2020-12-27 18:43:49 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Pressable style={styles.notificationView} onPress={onPress}>
|
|
|
|
<TimelineActioned
|
|
|
|
action={notification.type}
|
|
|
|
account={notification.account}
|
|
|
|
notification
|
|
|
|
/>
|
|
|
|
|
2020-12-30 11:52:47 +01:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
opacity:
|
2021-01-04 10:50:24 +01:00
|
|
|
notification.type === 'follow' ||
|
|
|
|
notification.type === 'follow_request' ||
|
|
|
|
notification.type === 'mention' ||
|
|
|
|
notification.type === 'status'
|
2020-12-30 11:52:47 +01:00
|
|
|
? 1
|
|
|
|
: 0.5
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<View style={styles.header}>
|
|
|
|
<TimelineAvatar queryKey={queryKey} account={actualAccount} />
|
|
|
|
<TimelineHeaderNotification notification={notification} />
|
2020-12-13 23:02:54 +01:00
|
|
|
</View>
|
2020-12-30 11:52:47 +01:00
|
|
|
|
|
|
|
{notification.status ? (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
|
|
|
paddingLeft: highlighted
|
|
|
|
? 0
|
|
|
|
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{notification.status.content.length > 0 && (
|
|
|
|
<TimelineContent
|
|
|
|
status={notification.status}
|
|
|
|
highlighted={highlighted}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{notification.status.poll && (
|
|
|
|
<TimelinePoll
|
|
|
|
queryKey={queryKey}
|
|
|
|
poll={notification.status.poll}
|
|
|
|
reblog={false}
|
|
|
|
sameAccount={notification.account.id === localAccountId}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{notification.status.media_attachments.length > 0 && (
|
2020-12-30 14:33:33 +01:00
|
|
|
<TimelineAttachment status={notification.status} />
|
2020-12-30 11:52:47 +01:00
|
|
|
)}
|
|
|
|
{notification.status.card && (
|
|
|
|
<TimelineCard card={notification.status.card} />
|
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
) : null}
|
|
|
|
</View>
|
2020-12-13 23:02:54 +01:00
|
|
|
|
|
|
|
{notification.status && (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
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-20 17:53:24 +01:00
|
|
|
<TimelineActions
|
|
|
|
queryKey={queryKey}
|
|
|
|
status={notification.status}
|
|
|
|
reblog={false}
|
|
|
|
/>
|
2020-12-13 23:02:54 +01:00
|
|
|
</View>
|
|
|
|
)}
|
2020-12-27 18:43:49 +01:00
|
|
|
</Pressable>
|
2020-12-12 18:22:22 +01:00
|
|
|
)
|
2020-11-04 22:26:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2020-11-06 00:59:33 +01:00
|
|
|
notificationView: {
|
2020-12-13 23:02:54 +01:00
|
|
|
padding: StyleConstants.Spacing.Global.PagePadding,
|
|
|
|
paddingBottom: StyleConstants.Spacing.M
|
2020-11-04 22:26:38 +01:00
|
|
|
},
|
2020-12-13 23:02:54 +01:00
|
|
|
header: {
|
2020-11-04 22:26:38 +01:00
|
|
|
flex: 1,
|
2020-12-13 23:02:54 +01:00
|
|
|
width: '100%',
|
2020-11-04 22:26:38 +01:00
|
|
|
flexDirection: 'row'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-11-23 00:07:32 +01:00
|
|
|
export default TimelineNotifications
|