2017-07-12 04:02:51 -04:00
|
|
|
// Package imports //
|
2017-07-05 21:51:03 -04:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
export default class StatusPrepend extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
parseClick: PropTypes.func.isRequired,
|
2017-07-14 11:03:43 -04:00
|
|
|
notificationId: PropTypes.number,
|
2017-07-05 21:51:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = (e) => {
|
|
|
|
const { account, parseClick } = this.props;
|
2019-02-21 15:13:12 -05:00
|
|
|
parseClick(e, `/accounts/${account.get('id')}`);
|
2017-07-05 21:51:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Message = () => {
|
|
|
|
const { type, account } = this.props;
|
|
|
|
let link = (
|
|
|
|
<a
|
|
|
|
onClick={this.handleClick}
|
|
|
|
href={account.get('url')}
|
|
|
|
className='status__display-name'
|
|
|
|
>
|
|
|
|
<b
|
|
|
|
dangerouslySetInnerHTML={{
|
2017-09-28 05:03:23 -04:00
|
|
|
__html : account.get('display_name_html') || account.get('username'),
|
2017-07-05 21:51:03 -04:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
switch (type) {
|
2018-03-16 15:29:42 -04:00
|
|
|
case 'featured':
|
|
|
|
return (
|
|
|
|
<FormattedMessage id='status.pinned' defaultMessage='Pinned toot' />
|
|
|
|
);
|
2017-07-05 21:51:03 -04:00
|
|
|
case 'reblogged_by':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='status.reblogged_by'
|
|
|
|
defaultMessage='{name} boosted'
|
|
|
|
values={{ name : link }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
case 'favourite':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.favourite'
|
|
|
|
defaultMessage='{name} favourited your status'
|
|
|
|
values={{ name : link }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
case 'reblog':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.reblog'
|
|
|
|
defaultMessage='{name} boosted your status'
|
|
|
|
values={{ name : link }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { Message } = this;
|
2017-07-21 14:33:16 -04:00
|
|
|
const { type } = this.props;
|
2017-07-05 21:51:03 -04:00
|
|
|
|
|
|
|
return !type ? null : (
|
2018-03-16 15:29:42 -04:00
|
|
|
<aside className={type === 'reblogged_by' || type === 'featured' ? 'status__prepend' : 'notification__message'}>
|
|
|
|
<div className={type === 'reblogged_by' || type === 'featured' ? 'status__prepend-icon-wrapper' : 'notification__favourite-icon-wrapper'}>
|
2017-07-05 21:51:03 -04:00
|
|
|
<i
|
|
|
|
className={`fa fa-fw fa-${
|
2018-03-16 15:29:42 -04:00
|
|
|
type === 'favourite' ? 'star star-icon' : (type === 'featured' ? 'thumb-tack' : 'retweet')
|
2017-07-05 21:51:03 -04:00
|
|
|
} status__prepend-icon`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<Message />
|
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|