tooot/src/components/Timelines/Timeline/Shared/Content.tsx

59 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-01-01 16:48:16 +01:00
import { ParseHTML } from '@components/Parse'
import { StyleConstants } from '@utils/styles/constants'
2020-12-26 12:59:16 +01:00
import React from 'react'
2021-01-01 23:10:47 +01:00
import { useTranslation } from 'react-i18next'
2020-12-26 12:59:16 +01:00
import { View } from 'react-native'
2020-11-23 00:07:32 +01:00
2020-10-31 21:04:46 +01:00
export interface Props {
2020-12-03 01:28:56 +01:00
status: Mastodon.Status
2020-12-02 00:16:27 +01:00
numberOfLines?: number
2020-12-12 22:19:18 +01:00
highlighted?: boolean
2020-10-31 21:04:46 +01:00
}
2020-12-12 22:19:18 +01:00
const TimelineContent: React.FC<Props> = ({
status,
numberOfLines,
highlighted = false
}) => {
2021-01-01 23:10:47 +01:00
const { t } = useTranslation('timeline')
2020-10-29 14:52:28 +01:00
return (
<>
2020-12-03 01:28:56 +01:00
{status.spoiler_text ? (
<>
2021-01-01 16:48:16 +01:00
<View style={{ marginBottom: StyleConstants.Font.Size.M }}>
<ParseHTML
content={status.spoiler_text}
2020-12-12 22:19:18 +01:00
size={highlighted ? 'L' : 'M'}
2020-12-03 01:28:56 +01:00
emojis={status.emojis}
mentions={status.mentions}
2020-12-28 17:30:20 +01:00
tags={status.tags}
2021-01-01 16:48:16 +01:00
numberOfLines={999}
2020-12-03 01:28:56 +01:00
/>
</View>
2021-01-01 16:48:16 +01:00
<ParseHTML
content={status.content}
size={highlighted ? 'L' : 'M'}
emojis={status.emojis}
mentions={status.mentions}
tags={status.tags}
numberOfLines={0}
2021-01-01 23:10:47 +01:00
expandHint={t('shared.content.expandHint')}
2021-01-01 16:48:16 +01:00
/>
2020-12-03 01:28:56 +01:00
</>
) : (
2021-01-01 16:48:16 +01:00
<ParseHTML
2020-12-03 01:28:56 +01:00
content={status.content}
2020-12-12 22:19:18 +01:00
size={highlighted ? 'L' : 'M'}
2020-12-03 01:28:56 +01:00
emojis={status.emojis}
mentions={status.mentions}
2020-12-28 17:30:20 +01:00
tags={status.tags}
2020-12-26 12:59:16 +01:00
numberOfLines={numberOfLines}
2020-12-03 01:28:56 +01:00
/>
)}
2020-10-29 14:52:28 +01:00
</>
)
}
2020-12-03 01:28:56 +01:00
export default React.memo(TimelineContent, () => true)