1 import React
from 'react';
2 import ImmutablePropTypes
from 'react-immutable-proptypes';
3 import StatusContainer
from '../../../containers/status_container';
4 import AccountContainer
from '../../../containers/account_container';
5 import Avatar
from '../../../components/avatar';
6 import { FormattedMessage
} from 'react-intl';
7 import Permalink
from '../../../components/permalink';
8 import emojify
from '../../../emoji';
9 import escapeTextContentForBrowser
from 'escape-html';
10 import ImmutablePureComponent
from 'react-immutable-pure-component';
12 class Notification
extends ImmutablePureComponent
{
15 notification: ImmutablePropTypes
.map
.isRequired
18 renderFollow (account
, link
) {
20 <div className
='notification notification-follow'>
21 <div className
='notification__message'>
22 <div className
='notification__favourite-icon-wrapper'>
23 <i className
='fa fa-fw fa-user-plus' />
26 <FormattedMessage id
='notification.follow' defaultMessage
='{name} followed you' values
={{ name: link
}} />
29 <AccountContainer id
={account
.get('id')} withNote
={false} />
34 renderMention (notification
) {
35 return <StatusContainer id
={notification
.get('status')} withDismiss
/>;
38 renderFavourite (notification
, link
) {
40 <div className
='notification notification-favourite'>
41 <div className
='notification__message'>
42 <div className
='notification__favourite-icon-wrapper'>
43 <i className
='fa fa-fw fa-star star-icon'/>
45 <FormattedMessage id
='notification.favourite' defaultMessage
='{name} favourited your status' values
={{ name: link
}} />
48 <StatusContainer id
={notification
.get('status')} account
={notification
.get('account')} muted
={true} withDismiss
/>
53 renderReblog (notification
, link
) {
55 <div className
='notification notification-reblog'>
56 <div className
='notification__message'>
57 <div className
='notification__favourite-icon-wrapper'>
58 <i className
='fa fa-fw fa-retweet' />
60 <FormattedMessage id
='notification.reblog' defaultMessage
='{name} boosted your status' values
={{ name: link
}} />
63 <StatusContainer id
={notification
.get('status')} account
={notification
.get('account')} muted
={true} withDismiss
/>
68 render () { // eslint-disable-line consistent-return
69 const { notification
} = this.props
;
70 const account
= notification
.get('account');
71 const displayName
= account
.get('display_name').length
> 0 ? account
.get('display_name') : account
.get('username');
72 const displayNameHTML
= { __html: emojify(escapeTextContentForBrowser(displayName
)) };
73 const link
= <Permalink className
='notification__display-name' href
={account
.get('url')} title
={account
.get('acct')} to
={`/accounts/${account.get('id')}`} dangerouslySetInnerHTML
={displayNameHTML
} />;
75 switch(notification
.get('type')) {
77 return this.renderFollow(account
, link
);
79 return this.renderMention(notification
);
81 return this.renderFavourite(notification
, link
);
83 return this.renderReblog(notification
, link
);
89 export default Notification
;