2017-12-24 01:16:45 -05:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
2019-04-20 16:21:28 -04:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2019-04-20 16:21:28 -04:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-12-24 01:16:45 -05:00
|
|
|
|
2018-07-28 17:08:38 -04:00
|
|
|
import AttachmentList from 'flavours/glitch/components/attachment_list';
|
2023-11-19 15:28:53 -05:00
|
|
|
import { WithOptionalRouterPropTypes, withOptionalRouter } from 'flavours/glitch/utils/react_router';
|
2023-11-16 12:02:01 -05:00
|
|
|
|
2023-11-19 15:28:53 -05:00
|
|
|
import { Avatar } from '../../../components/avatar';
|
|
|
|
import { DisplayName } from '../../../components/display_name';
|
2023-11-16 12:02:01 -05:00
|
|
|
import { IconButton } from '../../../components/icon_button';
|
2023-10-19 13:44:55 -04:00
|
|
|
|
2017-12-24 01:16:45 -05:00
|
|
|
const messages = defineMessages({
|
2023-10-19 13:44:55 -04:00
|
|
|
cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
|
2017-12-24 01:16:45 -05:00
|
|
|
});
|
|
|
|
|
2019-04-20 16:21:28 -04:00
|
|
|
class ReplyIndicator extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
2019-05-30 02:42:09 -04:00
|
|
|
status: ImmutablePropTypes.map,
|
2023-11-19 15:28:53 -05:00
|
|
|
onCancel: PropTypes.func.isRequired,
|
2023-11-16 12:02:01 -05:00
|
|
|
intl: PropTypes.object.isRequired,
|
2023-11-19 15:28:53 -05:00
|
|
|
...WithOptionalRouterPropTypes,
|
2019-04-20 16:21:28 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
2023-11-19 15:28:53 -05:00
|
|
|
this.props.onCancel();
|
|
|
|
};
|
|
|
|
|
|
|
|
handleAccountClick = (e) => {
|
|
|
|
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.history?.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
|
2017-12-24 01:16:45 -05:00
|
|
|
}
|
2023-02-03 14:52:07 -05:00
|
|
|
};
|
2017-12-24 01:16:45 -05:00
|
|
|
|
|
|
|
render () {
|
2019-04-20 16:21:28 -04:00
|
|
|
const { status, intl } = this.props;
|
|
|
|
|
|
|
|
if (!status) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-12-24 01:16:45 -05:00
|
|
|
|
2023-11-16 12:02:01 -05:00
|
|
|
const content = { __html: status.get('contentHtml') };
|
|
|
|
|
2017-12-24 01:16:45 -05:00
|
|
|
return (
|
2023-11-16 12:02:01 -05:00
|
|
|
<div className='reply-indicator'>
|
|
|
|
<div className='reply-indicator__header'>
|
|
|
|
<div className='reply-indicator__cancel'><IconButton title={intl.formatMessage(messages.cancel)} icon='times' onClick={this.handleClick} inverted /></div>
|
|
|
|
|
2023-11-19 15:28:53 -05:00
|
|
|
<a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='reply-indicator__display-name' target='_blank' rel='noopener noreferrer'>
|
|
|
|
<div className='reply-indicator__display-avatar'><Avatar account={status.get('account')} size={24} /></div>
|
|
|
|
<DisplayName account={status.get('account')} inline />
|
|
|
|
</a>
|
2023-11-16 12:02:01 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='reply-indicator__content translate' dangerouslySetInnerHTML={content} />
|
|
|
|
|
|
|
|
{status.get('media_attachments').size > 0 && (
|
2018-07-28 17:08:38 -04:00
|
|
|
<AttachmentList
|
|
|
|
compact
|
2023-11-16 12:02:01 -05:00
|
|
|
media={status.get('media_attachments')}
|
2018-07-28 17:08:38 -04:00
|
|
|
/>
|
|
|
|
)}
|
2023-11-16 12:02:01 -05:00
|
|
|
</div>
|
2017-12-24 01:16:45 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-24 18:15:25 -04:00
|
|
|
|
2023-11-19 15:28:53 -05:00
|
|
|
export default withOptionalRouter(injectIntl(ReplyIndicator));
|