2017-07-12 17:02:51 +09:00
|
|
|
// Package imports //
|
2017-07-06 10:51:03 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 23:38:10 +09:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
2017-07-06 10:51:03 +09:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
|
2024-01-16 19:27:26 +09:00
|
|
|
import EditIcon from '@/material-icons/400-24px/edit.svg?react';
|
|
|
|
import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react';
|
|
|
|
import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
|
|
|
|
import PushPinIcon from '@/material-icons/400-24px/push_pin.svg?react';
|
|
|
|
import RepeatIcon from '@/material-icons/400-24px/repeat.svg?react';
|
|
|
|
import StarIcon from '@/material-icons/400-24px/star-fill.svg?react';
|
2023-05-09 10:11:56 +09:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2022-10-11 17:17:04 +09:00
|
|
|
import { me } from 'flavours/glitch/initial_state';
|
2024-01-13 05:16:48 +09:00
|
|
|
|
2017-07-06 10:51:03 +09:00
|
|
|
|
2023-05-28 21:18:23 +09:00
|
|
|
export default class StatusPrepend extends PureComponent {
|
2017-07-06 10:51:03 +09:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
parseClick: PropTypes.func.isRequired,
|
2017-07-15 00:03:43 +09:00
|
|
|
notificationId: PropTypes.number,
|
2024-02-21 02:49:59 +09:00
|
|
|
children: PropTypes.node,
|
2017-07-06 10:51:03 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = (e) => {
|
|
|
|
const { account, parseClick } = this.props;
|
2021-09-30 18:47:58 +09:00
|
|
|
parseClick(e, `/@${account.get('acct')}`);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-07-06 10:51:03 +09:00
|
|
|
|
|
|
|
Message = () => {
|
|
|
|
const { type, account } = this.props;
|
|
|
|
let link = (
|
|
|
|
<a
|
|
|
|
onClick={this.handleClick}
|
|
|
|
href={account.get('url')}
|
|
|
|
className='status__display-name'
|
2024-06-27 04:33:38 +09:00
|
|
|
data-hover-card-account={account.get('id')}
|
2017-07-06 10:51:03 +09:00
|
|
|
>
|
2024-02-21 02:49:59 +09:00
|
|
|
<bdi>
|
|
|
|
<strong
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html : account.get('display_name_html') || account.get('username'),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</bdi>
|
2017-07-06 10:51:03 +09:00
|
|
|
</a>
|
|
|
|
);
|
|
|
|
switch (type) {
|
2018-03-17 04:29:42 +09:00
|
|
|
case 'featured':
|
|
|
|
return (
|
2022-05-03 17:59:23 +09:00
|
|
|
<FormattedMessage id='status.pinned' defaultMessage='Pinned post' />
|
2018-03-17 04:29:42 +09:00
|
|
|
);
|
2017-07-06 10:51:03 +09:00
|
|
|
case 'reblogged_by':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='status.reblogged_by'
|
|
|
|
defaultMessage='{name} boosted'
|
|
|
|
values={{ name : link }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
case 'favourite':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.favourite'
|
2024-08-30 18:37:39 +09:00
|
|
|
defaultMessage='{name} favorited your post'
|
2017-07-06 10:51:03 +09:00
|
|
|
values={{ name : link }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
case 'reblog':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.reblog'
|
2024-08-30 18:37:39 +09:00
|
|
|
defaultMessage='{name} boosted your post'
|
2017-07-06 10:51:03 +09:00
|
|
|
values={{ name : link }}
|
|
|
|
/>
|
|
|
|
);
|
2020-09-19 00:26:45 +09:00
|
|
|
case 'status':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.status'
|
|
|
|
defaultMessage='{name} just posted'
|
|
|
|
values={{ name: link }}
|
|
|
|
/>
|
|
|
|
);
|
2019-03-11 19:32:21 +09:00
|
|
|
case 'poll':
|
2019-11-06 23:06:53 +09:00
|
|
|
if (me === account.get('id')) {
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.own_poll'
|
|
|
|
defaultMessage='Your poll has ended'
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.poll'
|
2024-07-18 23:36:09 +09:00
|
|
|
defaultMessage='A poll you voted in has ended'
|
2019-11-06 23:06:53 +09:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-02-12 06:20:19 +09:00
|
|
|
case 'update':
|
|
|
|
return (
|
|
|
|
<FormattedMessage
|
|
|
|
id='notification.update'
|
|
|
|
defaultMessage='{name} edited a post'
|
|
|
|
values={{ name: link }}
|
|
|
|
/>
|
|
|
|
);
|
2017-07-06 10:51:03 +09:00
|
|
|
}
|
|
|
|
return null;
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-07-06 10:51:03 +09:00
|
|
|
|
|
|
|
render () {
|
|
|
|
const { Message } = this;
|
2024-02-21 02:49:59 +09:00
|
|
|
const { type, children } = this.props;
|
2017-07-06 10:51:03 +09:00
|
|
|
|
2023-10-25 02:45:08 +09:00
|
|
|
let iconId, iconComponent;
|
2020-09-19 00:26:45 +09:00
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 'favourite':
|
|
|
|
iconId = 'star';
|
2023-10-25 02:45:08 +09:00
|
|
|
iconComponent = StarIcon;
|
2020-09-19 00:26:45 +09:00
|
|
|
break;
|
|
|
|
case 'featured':
|
|
|
|
iconId = 'thumb-tack';
|
2023-10-25 02:45:08 +09:00
|
|
|
iconComponent = PushPinIcon;
|
2020-09-19 00:26:45 +09:00
|
|
|
break;
|
|
|
|
case 'poll':
|
|
|
|
iconId = 'tasks';
|
2023-10-25 02:45:08 +09:00
|
|
|
iconComponent = InsertChartIcon;
|
2020-09-19 00:26:45 +09:00
|
|
|
break;
|
2020-09-29 17:40:05 +09:00
|
|
|
case 'reblog':
|
2020-09-19 00:26:45 +09:00
|
|
|
case 'reblogged_by':
|
|
|
|
iconId = 'retweet';
|
2023-10-25 02:45:08 +09:00
|
|
|
iconComponent = RepeatIcon;
|
2020-09-19 00:26:45 +09:00
|
|
|
break;
|
|
|
|
case 'status':
|
|
|
|
iconId = 'bell';
|
2023-10-25 02:45:08 +09:00
|
|
|
iconComponent = HomeIcon;
|
2020-09-19 00:26:45 +09:00
|
|
|
break;
|
2022-02-12 06:20:19 +09:00
|
|
|
case 'update':
|
|
|
|
iconId = 'pencil';
|
2023-10-25 02:45:08 +09:00
|
|
|
iconComponent = EditIcon;
|
2022-02-12 06:20:19 +09:00
|
|
|
break;
|
2023-02-04 04:52:07 +09:00
|
|
|
}
|
2020-09-19 00:26:45 +09:00
|
|
|
|
2017-07-06 10:51:03 +09:00
|
|
|
return !type ? null : (
|
2018-03-17 04:29:42 +09:00
|
|
|
<aside className={type === 'reblogged_by' || type === 'featured' ? 'status__prepend' : 'notification__message'}>
|
2024-09-10 00:28:54 +09:00
|
|
|
<div className='status__prepend__icon'>
|
|
|
|
<Icon
|
|
|
|
className={type === 'favourite' ? 'star-icon' : null}
|
|
|
|
id={iconId}
|
|
|
|
icon={iconComponent}
|
|
|
|
/>
|
|
|
|
</div>
|
2017-07-06 10:51:03 +09:00
|
|
|
<Message />
|
2024-02-21 02:49:59 +09:00
|
|
|
{children}
|
2017-07-06 10:51:03 +09:00
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|