2021-01-01 16:48:16 +01:00
|
|
|
import { ParseHTML } from '@components/Parse'
|
2021-11-27 19:34:20 +01:00
|
|
|
import { getInstanceAccount } from '@utils/slices/instancesSlice'
|
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'
|
2021-11-27 19:34:20 +01:00
|
|
|
import { useSelector } from 'react-redux'
|
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
|
2021-01-04 18:29:02 +01:00
|
|
|
disableDetails?: boolean
|
2020-10-31 21:04:46 +01:00
|
|
|
}
|
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
const TimelineContent = React.memo(
|
|
|
|
({
|
|
|
|
status,
|
|
|
|
numberOfLines,
|
|
|
|
highlighted = false,
|
|
|
|
disableDetails = false
|
|
|
|
}: Props) => {
|
|
|
|
const { t } = useTranslation('componentTimeline')
|
2021-11-27 19:34:20 +01:00
|
|
|
const instanceAccount = useSelector(getInstanceAccount, () => true)
|
2021-01-01 23:10:47 +01:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{status.spoiler_text ? (
|
|
|
|
<>
|
2021-03-13 17:56:57 +01:00
|
|
|
<ParseHTML
|
|
|
|
content={status.spoiler_text}
|
|
|
|
size={highlighted ? 'L' : 'M'}
|
|
|
|
adaptiveSize
|
|
|
|
emojis={status.emojis}
|
|
|
|
mentions={status.mentions}
|
|
|
|
tags={status.tags}
|
|
|
|
numberOfLines={999}
|
2021-05-19 23:28:01 +02:00
|
|
|
highlighted={highlighted}
|
2021-03-13 17:56:57 +01:00
|
|
|
disableDetails={disableDetails}
|
2021-05-23 22:40:42 +02:00
|
|
|
selectable={highlighted}
|
2021-03-13 17:56:57 +01:00
|
|
|
/>
|
2021-01-01 16:48:16 +01:00
|
|
|
<ParseHTML
|
2021-02-27 16:33:54 +01:00
|
|
|
content={status.content}
|
2020-12-12 22:19:18 +01:00
|
|
|
size={highlighted ? 'L' : 'M'}
|
2021-03-10 10:22:53 +01:00
|
|
|
adaptiveSize
|
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-11-27 19:34:20 +01:00
|
|
|
numberOfLines={
|
|
|
|
instanceAccount.preferences['reading:expand:spoilers'] ? 999 : 1
|
|
|
|
}
|
2021-02-27 16:33:54 +01:00
|
|
|
expandHint={t('shared.content.expandHint')}
|
2021-05-19 23:28:01 +02:00
|
|
|
highlighted={highlighted}
|
2021-01-04 18:29:02 +01:00
|
|
|
disableDetails={disableDetails}
|
2021-05-23 22:40:42 +02:00
|
|
|
selectable={highlighted}
|
2020-12-03 01:28:56 +01:00
|
|
|
/>
|
2021-02-27 16:33:54 +01:00
|
|
|
</>
|
|
|
|
) : (
|
2021-01-01 16:48:16 +01:00
|
|
|
<ParseHTML
|
|
|
|
content={status.content}
|
|
|
|
size={highlighted ? 'L' : 'M'}
|
2021-03-10 10:22:53 +01:00
|
|
|
adaptiveSize
|
2021-01-01 16:48:16 +01:00
|
|
|
emojis={status.emojis}
|
|
|
|
mentions={status.mentions}
|
|
|
|
tags={status.tags}
|
2021-02-27 16:33:54 +01:00
|
|
|
numberOfLines={highlighted ? 999 : numberOfLines}
|
2021-01-04 18:29:02 +01:00
|
|
|
disableDetails={disableDetails}
|
2021-05-23 22:40:42 +02:00
|
|
|
selectable={highlighted}
|
2021-01-01 16:48:16 +01:00
|
|
|
/>
|
2021-02-27 16:33:54 +01:00
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
() => true
|
|
|
|
)
|
2020-10-29 14:52:28 +01:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
export default TimelineContent
|