2021-01-30 02:03:39 +01:00
|
|
|
import Icon from '@components/Icon'
|
|
|
|
import {
|
|
|
|
RelationshipIncoming,
|
|
|
|
RelationshipOutgoing
|
|
|
|
} from '@components/Relationship'
|
2022-06-17 00:10:15 +02:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
2021-01-01 16:48:16 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2021-01-30 02:03:39 +01:00
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2022-06-07 20:07:14 +02:00
|
|
|
import React, { useContext, useMemo } from 'react'
|
2022-04-30 21:29:08 +02:00
|
|
|
import { Pressable, View } from 'react-native'
|
2022-06-07 20:07:14 +02:00
|
|
|
import ContextMenu from 'react-native-context-menu-view'
|
|
|
|
import { ContextMenuContext } from './ContextMenu'
|
2021-01-03 02:00:26 +01:00
|
|
|
import HeaderSharedAccount from './HeaderShared/Account'
|
2021-01-01 23:10:47 +01:00
|
|
|
import HeaderSharedApplication from './HeaderShared/Application'
|
|
|
|
import HeaderSharedCreated from './HeaderShared/Created'
|
2021-01-11 21:36:57 +01:00
|
|
|
import HeaderSharedMuted from './HeaderShared/Muted'
|
2021-01-30 02:03:39 +01:00
|
|
|
import HeaderSharedVisibility from './HeaderShared/Visibility'
|
2020-12-12 18:22:22 +01:00
|
|
|
|
|
|
|
export interface Props {
|
2022-06-17 00:10:15 +02:00
|
|
|
queryKey: QueryKeyTimeline
|
2020-12-12 18:22:22 +01:00
|
|
|
notification: Mastodon.Notification
|
|
|
|
}
|
|
|
|
|
2022-06-07 20:07:14 +02:00
|
|
|
const TimelineHeaderNotification = ({ notification }: Props) => {
|
2022-04-30 21:29:08 +02:00
|
|
|
const { colors } = useTheme()
|
2021-01-30 02:03:39 +01:00
|
|
|
|
2022-06-07 20:07:14 +02:00
|
|
|
const contextMenuContext = useContext(ContextMenuContext)
|
|
|
|
|
2022-04-30 21:29:08 +02:00
|
|
|
const actions = useMemo(() => {
|
|
|
|
switch (notification.type) {
|
|
|
|
case 'follow':
|
|
|
|
return <RelationshipOutgoing id={notification.account.id} />
|
|
|
|
case 'follow_request':
|
|
|
|
return <RelationshipIncoming id={notification.account.id} />
|
|
|
|
default:
|
|
|
|
if (notification.status) {
|
|
|
|
return (
|
|
|
|
<Pressable
|
|
|
|
style={{
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingBottom: StyleConstants.Spacing.S
|
|
|
|
}}
|
|
|
|
children={
|
2022-06-07 20:07:14 +02:00
|
|
|
<ContextMenu
|
2022-06-17 00:14:32 +02:00
|
|
|
dropdownMenuMode
|
2022-06-07 20:07:14 +02:00
|
|
|
actions={contextMenuContext}
|
|
|
|
onPress={() => {}}
|
|
|
|
children={
|
|
|
|
<Icon
|
|
|
|
name='MoreHorizontal'
|
|
|
|
color={colors.secondary}
|
|
|
|
size={StyleConstants.Font.Size.L}
|
|
|
|
/>
|
|
|
|
}
|
2022-04-30 21:29:08 +02:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [notification.type])
|
2021-02-27 16:33:54 +01:00
|
|
|
|
2022-04-30 21:29:08 +02:00
|
|
|
return (
|
|
|
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flex:
|
|
|
|
notification.type === 'follow' ||
|
|
|
|
notification.type === 'follow_request'
|
|
|
|
? 1
|
|
|
|
: 4
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<HeaderSharedAccount
|
|
|
|
account={
|
|
|
|
notification.status
|
|
|
|
? notification.status.account
|
|
|
|
: notification.account
|
|
|
|
}
|
|
|
|
{...((notification.type === 'follow' ||
|
|
|
|
notification.type === 'follow_request') && { withoutName: true })}
|
|
|
|
/>
|
2021-02-27 16:33:54 +01:00
|
|
|
<View
|
|
|
|
style={{
|
2022-04-30 21:29:08 +02:00
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
marginTop: StyleConstants.Spacing.XS,
|
|
|
|
marginBottom: StyleConstants.Spacing.S
|
2021-02-27 16:33:54 +01:00
|
|
|
}}
|
|
|
|
>
|
2022-04-30 21:29:08 +02:00
|
|
|
<HeaderSharedCreated
|
2022-06-03 23:27:22 +02:00
|
|
|
created_at={
|
|
|
|
notification.status?.created_at || notification.created_at
|
|
|
|
}
|
2022-04-30 21:29:08 +02:00
|
|
|
edited_at={notification.status?.edited_at}
|
2021-02-27 16:33:54 +01:00
|
|
|
/>
|
2022-04-30 21:29:08 +02:00
|
|
|
{notification.status?.visibility ? (
|
|
|
|
<HeaderSharedVisibility
|
|
|
|
visibility={notification.status.visibility}
|
2021-01-30 02:03:39 +01:00
|
|
|
/>
|
2022-04-30 21:29:08 +02:00
|
|
|
) : null}
|
|
|
|
<HeaderSharedMuted muted={notification.status?.muted} />
|
|
|
|
<HeaderSharedApplication
|
|
|
|
application={notification.status?.application}
|
|
|
|
/>
|
2020-12-12 18:22:22 +01:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
|
2022-04-30 21:29:08 +02:00
|
|
|
<View
|
|
|
|
style={[
|
|
|
|
{ marginLeft: StyleConstants.Spacing.M },
|
|
|
|
notification.type === 'follow' ||
|
|
|
|
notification.type === 'follow_request'
|
|
|
|
? { flexShrink: 1 }
|
|
|
|
: { flex: 1 }
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{actions}
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
2020-12-12 18:22:22 +01:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
export default TimelineHeaderNotification
|