2020-04-02 04:17:21 +01:00
|
|
|
import { NavLink } from 'react-router-dom'
|
|
|
|
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import Icon from './icon'
|
|
|
|
import Text from './text'
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
filtered: { id: 'status.filtered', defaultMessage: 'Filtered' },
|
|
|
|
promoted: { id: 'status.promoted', defaultMessage: 'Promoted gab' },
|
|
|
|
pinned: { id: 'status.pinned', defaultMessage: 'Pinned gab' },
|
|
|
|
reposted: { id: 'status.reposted_by', defaultMessage: '{name} reposted' },
|
|
|
|
})
|
|
|
|
|
|
|
|
export default
|
|
|
|
@injectIntl
|
|
|
|
class StatusPrepend extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
status: ImmutablePropTypes.map,
|
2020-04-22 06:00:11 +01:00
|
|
|
isFeatured: PropTypes.bool,
|
|
|
|
isPromoted: PropTypes.bool,
|
2020-04-02 04:17:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
status,
|
2020-04-22 06:00:11 +01:00
|
|
|
isFeatured,
|
|
|
|
isPromoted,
|
2020-04-02 04:17:21 +01:00
|
|
|
} = this.props
|
|
|
|
|
|
|
|
if (!status) return null
|
|
|
|
|
|
|
|
const isRepost = (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object')
|
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
if (!isFeatured && !isPromoted && !isRepost) return null
|
2020-04-02 04:17:21 +01:00
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
const iconId = isFeatured ? 'pin' : isPromoted ? 'star' : 'repost'
|
2020-04-02 04:17:21 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={[_s.default, _s.width100PC, _s.alignItemsStart, _s.borderBottom1PX, _s.borderColorSecondary].join(' ')}>
|
|
|
|
<div className={[_s.default, _s.width100PC, _s.flexRow, _s.alignItemsCenter, _s.py5, _s.px15].join(' ')}>
|
2020-04-23 07:13:29 +01:00
|
|
|
<Icon id={iconId} size='12px' className={[_s.fillColorSecondary, _s.mr5].join(' ')} />
|
2020-04-02 04:17:21 +01:00
|
|
|
{
|
|
|
|
isRepost &&
|
|
|
|
<div className={[_s.default, _s.flexRow].join(' ')}>
|
|
|
|
<Text size='small' color='secondary'>
|
|
|
|
<FormattedMessage
|
|
|
|
id='status.reposted_by'
|
|
|
|
defaultMessage='{name} reposted'
|
|
|
|
values={{
|
|
|
|
name: (
|
|
|
|
<NavLink
|
|
|
|
className={[_s.noUnderline, _s.underline_onHover].join(' ')}
|
|
|
|
to={`/${status.getIn(['account', 'acct'])}`}
|
|
|
|
>
|
|
|
|
<Text size='small' color='secondary'>
|
|
|
|
<bdi>
|
|
|
|
<span dangerouslySetInnerHTML={{ __html: status.getIn(['account', 'display_name_html']) }} />
|
|
|
|
</bdi>
|
|
|
|
</Text>
|
|
|
|
</NavLink>
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Text>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
!isRepost &&
|
|
|
|
<Text color='secondary' size='small'>
|
2020-04-22 06:00:11 +01:00
|
|
|
{intl.formatMessage(isFeatured ? messages.pinned : messages.promoted)}
|
2020-04-02 04:17:21 +01:00
|
|
|
</Text>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|