2017-11-18 12:11:18 +09:00
|
|
|
// Package imports.
|
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
2016-11-21 03:39:18 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-05-03 09:04:16 +09:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2016-11-21 03:39:18 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
// Our imports,
|
2017-12-04 16:26:40 +09:00
|
|
|
import StatusContainer from 'flavours/glitch/containers/status_container';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
|
|
|
import NotificationAdminReportContainer from '../containers/admin_report_container';
|
2019-12-02 01:25:29 +09:00
|
|
|
import NotificationFollowRequestContainer from '../containers/follow_request_container';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
2022-02-24 00:45:22 +09:00
|
|
|
import NotificationAdminSignup from './admin_signup';
|
2023-05-28 23:38:10 +09:00
|
|
|
import NotificationFollow from './follow';
|
|
|
|
|
2017-06-24 02:36:54 +09:00
|
|
|
export default class Notification extends ImmutablePureComponent {
|
2016-11-21 03:39:18 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
static propTypes = {
|
2017-05-21 00:31:47 +09:00
|
|
|
notification: ImmutablePropTypes.map.isRequired,
|
2017-11-18 12:11:18 +09:00
|
|
|
hidden: PropTypes.bool,
|
|
|
|
onMoveUp: PropTypes.func.isRequired,
|
|
|
|
onMoveDown: PropTypes.func.isRequired,
|
|
|
|
onMention: PropTypes.func.isRequired,
|
2018-04-16 04:29:03 +09:00
|
|
|
getScrollPosition: PropTypes.func,
|
|
|
|
updateScrollBottom: PropTypes.func,
|
2019-02-10 04:54:11 +09:00
|
|
|
cacheMediaWidth: PropTypes.func,
|
|
|
|
cachedMediaWidth: PropTypes.number,
|
|
|
|
onUnmount: PropTypes.func,
|
2020-09-19 20:53:24 +09:00
|
|
|
unread: PropTypes.bool,
|
2017-05-12 21:44:10 +09:00
|
|
|
};
|
|
|
|
|
2017-06-11 17:42:42 +09:00
|
|
|
render () {
|
2017-11-28 06:17:12 +09:00
|
|
|
const {
|
|
|
|
hidden,
|
|
|
|
notification,
|
|
|
|
onMoveDown,
|
|
|
|
onMoveUp,
|
|
|
|
onMention,
|
2018-04-16 04:29:03 +09:00
|
|
|
getScrollPosition,
|
|
|
|
updateScrollBottom,
|
2017-11-28 06:17:12 +09:00
|
|
|
} = this.props;
|
|
|
|
|
2016-11-21 03:39:18 +09:00
|
|
|
switch(notification.get('type')) {
|
2017-04-12 05:53:58 +09:00
|
|
|
case 'follow':
|
2017-11-28 06:17:12 +09:00
|
|
|
return (
|
|
|
|
<NotificationFollow
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('id')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2020-09-16 01:09:08 +09:00
|
|
|
unread={this.props.unread}
|
2017-11-28 06:17:12 +09:00
|
|
|
/>
|
|
|
|
);
|
2019-12-02 01:25:29 +09:00
|
|
|
case 'follow_request':
|
|
|
|
return (
|
|
|
|
<NotificationFollowRequestContainer
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('id')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2020-09-16 01:09:08 +09:00
|
|
|
unread={this.props.unread}
|
2019-12-02 01:25:29 +09:00
|
|
|
/>
|
|
|
|
);
|
2022-02-24 00:45:22 +09:00
|
|
|
case 'admin.sign_up':
|
|
|
|
return (
|
|
|
|
<NotificationAdminSignup
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('id')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
|
|
|
unread={this.props.unread}
|
|
|
|
/>
|
|
|
|
);
|
2022-06-27 16:30:15 +09:00
|
|
|
case 'admin.report':
|
|
|
|
return (
|
|
|
|
<NotificationAdminReportContainer
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('id')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
|
|
|
unread={this.props.unread}
|
|
|
|
/>
|
|
|
|
);
|
2017-04-12 05:53:58 +09:00
|
|
|
case 'mention':
|
2017-11-28 06:17:12 +09:00
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2018-07-09 03:13:00 +09:00
|
|
|
contextType='notifications'
|
2018-04-16 04:29:03 +09:00
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
2019-02-10 04:54:11 +09:00
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
2017-11-28 06:17:12 +09:00
|
|
|
withDismiss
|
2020-09-16 01:09:08 +09:00
|
|
|
unread={this.props.unread}
|
2017-11-28 06:17:12 +09:00
|
|
|
/>
|
|
|
|
);
|
2020-09-19 00:26:45 +09:00
|
|
|
case 'status':
|
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
prepend='status'
|
|
|
|
muted
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2023-01-23 21:21:50 +09:00
|
|
|
contextType='notifications'
|
2020-09-19 00:26:45 +09:00
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
|
|
|
withDismiss
|
|
|
|
unread={this.props.unread}
|
|
|
|
/>
|
|
|
|
);
|
2017-04-12 05:53:58 +09:00
|
|
|
case 'favourite':
|
2017-11-28 06:17:12 +09:00
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
prepend='favourite'
|
|
|
|
muted
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2023-01-23 21:21:50 +09:00
|
|
|
contextType='notifications'
|
2018-04-16 04:29:03 +09:00
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
2019-02-10 04:54:11 +09:00
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
2017-11-28 06:17:12 +09:00
|
|
|
withDismiss
|
2020-09-16 01:09:08 +09:00
|
|
|
unread={this.props.unread}
|
2017-11-28 06:17:12 +09:00
|
|
|
/>
|
|
|
|
);
|
2022-11-29 12:31:22 +09:00
|
|
|
case 'reaction':
|
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
prepend='reaction'
|
|
|
|
muted
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
|
|
|
withDismiss
|
|
|
|
unread={this.props.unread}
|
|
|
|
/>
|
|
|
|
);
|
2017-04-12 05:53:58 +09:00
|
|
|
case 'reblog':
|
2017-11-28 06:17:12 +09:00
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
prepend='reblog'
|
|
|
|
muted
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2023-01-23 21:21:50 +09:00
|
|
|
contextType='notifications'
|
2018-04-16 04:29:03 +09:00
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
2019-02-10 04:54:11 +09:00
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
2017-11-28 06:17:12 +09:00
|
|
|
withDismiss
|
2020-09-16 01:09:08 +09:00
|
|
|
unread={this.props.unread}
|
2017-11-28 06:17:12 +09:00
|
|
|
/>
|
|
|
|
);
|
2019-03-11 19:32:21 +09:00
|
|
|
case 'poll':
|
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
prepend='poll'
|
|
|
|
muted
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2023-01-23 21:21:50 +09:00
|
|
|
contextType='notifications'
|
2019-03-11 19:32:21 +09:00
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
|
|
|
withDismiss
|
2020-09-16 01:09:08 +09:00
|
|
|
unread={this.props.unread}
|
2019-03-11 19:32:21 +09:00
|
|
|
/>
|
|
|
|
);
|
2022-02-12 06:20:19 +09:00
|
|
|
case 'update':
|
|
|
|
return (
|
|
|
|
<StatusContainer
|
|
|
|
containerId={notification.get('id')}
|
|
|
|
hidden={hidden}
|
|
|
|
id={notification.get('status')}
|
|
|
|
account={notification.get('account')}
|
|
|
|
prepend='update'
|
|
|
|
muted
|
|
|
|
notification={notification}
|
|
|
|
onMoveDown={onMoveDown}
|
|
|
|
onMoveUp={onMoveUp}
|
|
|
|
onMention={onMention}
|
2023-01-23 21:21:50 +09:00
|
|
|
contextType='notifications'
|
2022-02-12 06:20:19 +09:00
|
|
|
getScrollPosition={getScrollPosition}
|
|
|
|
updateScrollBottom={updateScrollBottom}
|
|
|
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
|
|
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
|
|
|
onUnmount={this.props.onUnmount}
|
|
|
|
withDismiss
|
|
|
|
unread={this.props.unread}
|
|
|
|
/>
|
|
|
|
);
|
2017-11-18 12:11:18 +09:00
|
|
|
default:
|
|
|
|
return null;
|
2016-11-21 03:39:18 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|