-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Content.tsx
82 lines (76 loc) · 2.59 KB
/
Content.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { ParseHTML } from '@components/Parse'
import CustomText from '@components/Text'
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import React, { useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { View } from 'react-native'
import StatusContext from './Context'
export interface Props {
notificationOwnToot?: boolean
setSpoilerExpanded?: React.Dispatch<React.SetStateAction<boolean>>
}
const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoilerExpanded }) => {
const { status, highlighted, suppressSpoiler, inThread } = useContext(StatusContext)
if (!status || typeof status.content !== 'string' || !status.content.length) return null
const { colors } = useTheme()
const { t } = useTranslation('componentTimeline')
const { data: preferences } = usePreferencesQuery()
return (
<View>
{/* <CustomText
children={excludeMentions?.current.map(mention => mention.username).join(' - ')}
style={{ color: colors.secondary }}
/> */}
{status.spoiler_text?.length ? (
<>
<ParseHTML
content={status.spoiler_text}
size={highlighted ? 'L' : 'M'}
adaptiveSize
numberOfLines={999}
color={suppressSpoiler ? colors.disabled : undefined}
selectable
/>
{inThread ? (
<CustomText
fontStyle='S'
style={{
textAlign: 'center',
color: colors.secondary,
paddingVertical: StyleConstants.Spacing.XS
}}
>
{t('shared.content.expandHint')}
</CustomText>
) : null}
<ParseHTML
content={status.content}
size={highlighted ? 'L' : 'M'}
adaptiveSize
numberOfLines={
preferences?.['reading:expand:spoilers'] || inThread
? notificationOwnToot
? 2
: 999
: 1
}
expandHint={t('shared.content.expandHint')}
setSpoilerExpanded={setSpoilerExpanded}
selectable
/>
</>
) : (
<ParseHTML
content={status.content}
size={highlighted ? 'L' : 'M'}
adaptiveSize
numberOfLines={highlighted || inThread ? 999 : notificationOwnToot ? 2 : undefined}
selectable
/>
)}
</View>
)
}
export default TimelineContent