You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
235 lines
7.2 KiB
235 lines
7.2 KiB
7 years ago
|
// Package imports.
|
||
8 years ago
|
import React from 'react';
|
||
7 years ago
|
import PropTypes from 'prop-types';
|
||
8 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
8 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
8 years ago
|
|
||
7 years ago
|
// Our imports,
|
||
7 years ago
|
import StatusContainer from 'flavours/glitch/containers/status_container';
|
||
7 years ago
|
import NotificationFollow from './follow';
|
||
5 years ago
|
import NotificationFollowRequestContainer from '../containers/follow_request_container';
|
||
3 years ago
|
import NotificationAdminSignup from './admin_signup';
|
||
2 years ago
|
import NotificationAdminReportContainer from '../containers/admin_report_container';
|
||
7 years ago
|
|
||
8 years ago
|
export default class Notification extends ImmutablePureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
static propTypes = {
|
||
8 years ago
|
notification: ImmutablePropTypes.map.isRequired,
|
||
7 years ago
|
hidden: PropTypes.bool,
|
||
|
onMoveUp: PropTypes.func.isRequired,
|
||
|
onMoveDown: PropTypes.func.isRequired,
|
||
|
onMention: PropTypes.func.isRequired,
|
||
7 years ago
|
getScrollPosition: PropTypes.func,
|
||
|
updateScrollBottom: PropTypes.func,
|
||
6 years ago
|
cacheMediaWidth: PropTypes.func,
|
||
|
cachedMediaWidth: PropTypes.number,
|
||
|
onUnmount: PropTypes.func,
|
||
4 years ago
|
unread: PropTypes.bool,
|
||
8 years ago
|
};
|
||
|
|
||
8 years ago
|
render () {
|
||
7 years ago
|
const {
|
||
|
hidden,
|
||
|
notification,
|
||
|
onMoveDown,
|
||
|
onMoveUp,
|
||
|
onMention,
|
||
7 years ago
|
getScrollPosition,
|
||
|
updateScrollBottom,
|
||
7 years ago
|
} = this.props;
|
||
|
|
||
8 years ago
|
switch(notification.get('type')) {
|
||
8 years ago
|
case 'follow':
|
||
7 years ago
|
return (
|
||
|
<NotificationFollow
|
||
|
hidden={hidden}
|
||
|
id={notification.get('id')}
|
||
|
account={notification.get('account')}
|
||
|
notification={notification}
|
||
|
onMoveDown={onMoveDown}
|
||
|
onMoveUp={onMoveUp}
|
||
|
onMention={onMention}
|
||
4 years ago
|
unread={this.props.unread}
|
||
7 years ago
|
/>
|
||
|
);
|
||
5 years ago
|
case 'follow_request':
|
||
|
return (
|
||
|
<NotificationFollowRequestContainer
|
||
|
hidden={hidden}
|
||
|
id={notification.get('id')}
|
||
|
account={notification.get('account')}
|
||
|
notification={notification}
|
||
|
onMoveDown={onMoveDown}
|
||
|
onMoveUp={onMoveUp}
|
||
|
onMention={onMention}
|
||
4 years ago
|
unread={this.props.unread}
|
||
5 years ago
|
/>
|
||
|
);
|
||
3 years ago
|
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}
|
||
|
/>
|
||
|
);
|
||
2 years ago
|
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}
|
||
|
/>
|
||
|
);
|
||
8 years ago
|
case 'mention':
|
||
7 years ago
|
return (
|
||
|
<StatusContainer
|
||
|
containerId={notification.get('id')}
|
||
|
hidden={hidden}
|
||
|
id={notification.get('status')}
|
||
|
notification={notification}
|
||
|
onMoveDown={onMoveDown}
|
||
|
onMoveUp={onMoveUp}
|
||
|
onMention={onMention}
|
||
6 years ago
|
contextType='notifications'
|
||
7 years ago
|
getScrollPosition={getScrollPosition}
|
||
|
updateScrollBottom={updateScrollBottom}
|
||
6 years ago
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
||
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
||
|
onUnmount={this.props.onUnmount}
|
||
7 years ago
|
withDismiss
|
||
4 years ago
|
unread={this.props.unread}
|
||
7 years ago
|
/>
|
||
|
);
|
||
4 years ago
|
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}
|
||
2 years ago
|
contextType='notifications'
|
||
4 years ago
|
getScrollPosition={getScrollPosition}
|
||
|
updateScrollBottom={updateScrollBottom}
|
||
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
||
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
||
|
onUnmount={this.props.onUnmount}
|
||
|
withDismiss
|
||
|
unread={this.props.unread}
|
||
|
/>
|
||
|
);
|
||
8 years ago
|
case 'favourite':
|
||
7 years ago
|
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}
|
||
2 years ago
|
contextType='notifications'
|
||
7 years ago
|
getScrollPosition={getScrollPosition}
|
||
|
updateScrollBottom={updateScrollBottom}
|
||
6 years ago
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
||
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
||
|
onUnmount={this.props.onUnmount}
|
||
7 years ago
|
withDismiss
|
||
4 years ago
|
unread={this.props.unread}
|
||
7 years ago
|
/>
|
||
|
);
|
||
8 years ago
|
case 'reblog':
|
||
7 years ago
|
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}
|
||
2 years ago
|
contextType='notifications'
|
||
7 years ago
|
getScrollPosition={getScrollPosition}
|
||
|
updateScrollBottom={updateScrollBottom}
|
||
6 years ago
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
||
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
||
|
onUnmount={this.props.onUnmount}
|
||
7 years ago
|
withDismiss
|
||
4 years ago
|
unread={this.props.unread}
|
||
7 years ago
|
/>
|
||
|
);
|
||
6 years ago
|
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}
|
||
2 years ago
|
contextType='notifications'
|
||
6 years ago
|
getScrollPosition={getScrollPosition}
|
||
|
updateScrollBottom={updateScrollBottom}
|
||
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
||
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
||
|
onUnmount={this.props.onUnmount}
|
||
|
withDismiss
|
||
4 years ago
|
unread={this.props.unread}
|
||
6 years ago
|
/>
|
||
|
);
|
||
3 years ago
|
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}
|
||
2 years ago
|
contextType='notifications'
|
||
3 years ago
|
getScrollPosition={getScrollPosition}
|
||
|
updateScrollBottom={updateScrollBottom}
|
||
|
cachedMediaWidth={this.props.cachedMediaWidth}
|
||
|
cacheMediaWidth={this.props.cacheMediaWidth}
|
||
|
onUnmount={this.props.onUnmount}
|
||
|
withDismiss
|
||
|
unread={this.props.unread}
|
||
|
/>
|
||
|
);
|
||
7 years ago
|
default:
|
||
|
return null;
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
}
|