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 {
|
2022-05-08 23:40:42 +02:00
|
|
|
status: Pick<Mastodon.Status, 'content' | 'spoiler_text' | 'emojis'> & {
|
|
|
|
mentions?: Mastodon.Status['mentions']
|
|
|
|
tags?: Mastodon.Status['tags']
|
|
|
|
}
|
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(
|
2022-10-10 23:28:40 +02:00
|
|
|
({ status, highlighted = false, disableDetails = false }: Props) => {
|
2021-02-27 16:33:54 +01:00
|
|
|
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-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}
|
2022-10-10 23:28:40 +02: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}
|
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}
|
2022-10-10 23:28:40 +02:00
|
|
|
numberOfLines={highlighted ? 999 : undefined}
|
2021-01-04 18:29:02 +01:00
|
|
|
disableDetails={disableDetails}
|
2021-01-01 16:48:16 +01:00
|
|
|
/>
|
2021-02-27 16:33:54 +01:00
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
},
|
2022-04-30 21:47:17 +02:00
|
|
|
(prev, next) =>
|
|
|
|
prev.status.content === next.status.content &&
|
|
|
|
prev.status.spoiler_text === next.status.spoiler_text
|
2021-02-27 16:33:54 +01:00
|
|
|
)
|
2020-10-29 14:52:28 +01:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
export default TimelineContent
|