2017-07-12 11:02:51 +03:00
|
|
|
// Package imports //
|
2017-07-06 04:51:03 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2019-09-09 17:41:41 +03:00
|
|
|
import Icon from 'flavours/glitch/components/icon';
|
2022-10-11 11:17:04 +03:00
|
|
|
import { me } from 'flavours/glitch/initial_state';
|
2017-07-06 04:51:03 +03:00
|
|
|
|
|
|
|
export default class StatusPrepend extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
parseClick: PropTypes.func.isRequired,
|
2017-07-14 18:03:43 +03:00
|
|
|
notificationId: PropTypes.number,
|
2017-07-06 04:51:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = (e) => {
|
|
|
|
const { account, parseClick } = this.props;
|
2021-09-30 12:47:58 +03:00
|
|
|
parseClick(e, `/@${account.get('acct')}`);
|
2017-07-06 04:51:03 +03: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 12:03:23 +03:00
|
|
|
__html : account.get('display_name_html') || account.get('username'),
|
2017-07-06 04:51:03 +03:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
switch (type) {
|
2018-03-16 21:29:42 +02:00
|
|
|
case 'featured':
|
|
|
|
return (
|
2022-05-03 11:59:23 +03:00
|
|
|
<FormattedMessage id='status.pinned' defaultMessage='Pinned post' />
|
2018-03-16 21:29:42 +02:00
|
|
|
);
|
2017-07-06 04:51:03 +03: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 }}
|
|
|
|
/>
|
|
|
|
);
|
2020-09-18 18:26:45 +03:00
|
|
|
case 'status':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.status'
|
|
|
|
defaultMessage='{name} just posted'
|
|
|
|
values={{ name: link }}
|
|
|
|
/>
|
|
|
|
);
|
2019-03-11 12:32:21 +02:00
|
|
|
case 'poll':
|
2019-11-06 16:06:53 +02:00
|
|
|
if (me === account.get('id')) {
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.own_poll'
|
|
|
|
defaultMessage='Your poll has ended'
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.poll'
|
|
|
|
defaultMessage='A poll you have voted in has ended'
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-02-11 23:20:19 +02:00
|
|
|
case 'update':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.update'
|
|
|
|
defaultMessage='{name} edited a post'
|
|
|
|
values={{ name: link }}
|
|
|
|
/>
|
|
|
|
);
|
2017-07-06 04:51:03 +03:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { Message } = this;
|
2017-07-21 21:33:16 +03:00
|
|
|
const { type } = this.props;
|
2017-07-06 04:51:03 +03:00
|
|
|
|
2020-09-18 18:26:45 +03:00
|
|
|
let iconId;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 'favourite':
|
|
|
|
iconId = 'star';
|
|
|
|
break;
|
|
|
|
case 'featured':
|
|
|
|
iconId = 'thumb-tack';
|
|
|
|
break;
|
|
|
|
case 'poll':
|
|
|
|
iconId = 'tasks';
|
|
|
|
break;
|
2020-09-29 11:40:05 +03:00
|
|
|
case 'reblog':
|
2020-09-18 18:26:45 +03:00
|
|
|
case 'reblogged_by':
|
|
|
|
iconId = 'retweet';
|
|
|
|
break;
|
|
|
|
case 'status':
|
|
|
|
iconId = 'bell';
|
|
|
|
break;
|
2022-02-11 23:20:19 +02:00
|
|
|
case 'update':
|
|
|
|
iconId = 'pencil';
|
|
|
|
break;
|
2020-09-18 18:26:45 +03:00
|
|
|
};
|
|
|
|
|
2017-07-06 04:51:03 +03:00
|
|
|
return !type ? null : (
|
2018-03-16 21:29:42 +02: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'}>
|
2019-09-09 17:41:41 +03:00
|
|
|
<Icon
|
|
|
|
className={`status__prepend-icon ${type === 'favourite' ? 'star-icon' : ''}`}
|
2020-09-18 18:26:45 +03:00
|
|
|
id={iconId}
|
2017-07-06 04:51:03 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<Message />
|
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|