diff options
Diffstat (limited to 'app/javascript/mastodon/features/notifications')
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/clear_column_button.jsx (renamed from app/javascript/mastodon/features/notifications/components/clear_column_button.js) | 2 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/column_settings.jsx (renamed from app/javascript/mastodon/features/notifications/components/column_settings.js) | 2 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/filter_bar.jsx (renamed from app/javascript/mastodon/features/notifications/components/filter_bar.js) | 3 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/follow_request.jsx (renamed from app/javascript/mastodon/features/notifications/components/follow_request.js) | 9 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx (renamed from app/javascript/mastodon/features/notifications/components/grant_permission_button.js) | 2 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/notification.jsx (renamed from app/javascript/mastodon/features/notifications/components/notification.js) | 58 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/notifications_permission_banner.jsx (renamed from app/javascript/mastodon/features/notifications/components/notifications_permission_banner.js) | 8 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/report.jsx (renamed from app/javascript/mastodon/features/notifications/components/report.js) | 3 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/components/setting_toggle.jsx (renamed from app/javascript/mastodon/features/notifications/components/setting_toggle.js) | 4 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/containers/column_settings_container.js | 3 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/containers/notification_container.js | 2 | ||||
-rw-r--r-- | app/javascript/mastodon/features/notifications/index.jsx (renamed from app/javascript/mastodon/features/notifications/index.js) | 16 |
12 files changed, 65 insertions, 47 deletions
diff --git a/app/javascript/mastodon/features/notifications/components/clear_column_button.js b/app/javascript/mastodon/features/notifications/components/clear_column_button.jsx index b82fd092f..9a076ce5e 100644 --- a/app/javascript/mastodon/features/notifications/components/clear_column_button.js +++ b/app/javascript/mastodon/features/notifications/components/clear_column_button.jsx @@ -11,7 +11,7 @@ export default class ClearColumnButton extends React.PureComponent { render () { return ( - <button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.props.onClick}><Icon id='eraser' /> <FormattedMessage id='notifications.clear' defaultMessage='Clear notifications' /></button> + <button className='text-btn column-header__setting-btn' tabIndex={0} onClick={this.props.onClick}><Icon id='eraser' /> <FormattedMessage id='notifications.clear' defaultMessage='Clear notifications' /></button> ); } diff --git a/app/javascript/mastodon/features/notifications/components/column_settings.js b/app/javascript/mastodon/features/notifications/components/column_settings.jsx index a38f8d3c2..9251847ba 100644 --- a/app/javascript/mastodon/features/notifications/components/column_settings.js +++ b/app/javascript/mastodon/features/notifications/components/column_settings.jsx @@ -26,7 +26,7 @@ export default class ColumnSettings extends React.PureComponent { onPushChange = (path, checked) => { this.props.onChange(['push', ...path], checked); - } + }; render () { const { settings, pushSettings, onChange, onClear, alertsEnabled, browserSupport, browserPermission, onRequestNotificationPermission } = this.props; diff --git a/app/javascript/mastodon/features/notifications/components/filter_bar.js b/app/javascript/mastodon/features/notifications/components/filter_bar.jsx index 368eb0b7e..88e95cf48 100644 --- a/app/javascript/mastodon/features/notifications/components/filter_bar.js +++ b/app/javascript/mastodon/features/notifications/components/filter_bar.jsx @@ -12,7 +12,6 @@ const tooltips = defineMessages({ statuses: { id: 'notifications.filter.statuses', defaultMessage: 'Updates from people you follow' }, }); -export default @injectIntl class FilterBar extends React.PureComponent { static propTypes = { @@ -108,3 +107,5 @@ class FilterBar extends React.PureComponent { } } + +export default injectIntl(FilterBar); diff --git a/app/javascript/mastodon/features/notifications/components/follow_request.js b/app/javascript/mastodon/features/notifications/components/follow_request.jsx index 08de875e3..01bf67065 100644 --- a/app/javascript/mastodon/features/notifications/components/follow_request.js +++ b/app/javascript/mastodon/features/notifications/components/follow_request.jsx @@ -1,4 +1,4 @@ -import React, { Fragment } from 'react'; +import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import Avatar from 'mastodon/components/avatar'; @@ -13,7 +13,6 @@ const messages = defineMessages({ reject: { id: 'follow_request.reject', defaultMessage: 'Reject' }, }); -export default @injectIntl class FollowRequest extends ImmutablePureComponent { static propTypes = { @@ -32,10 +31,10 @@ class FollowRequest extends ImmutablePureComponent { if (hidden) { return ( - <Fragment> + <React.Fragment> {account.get('display_name')} {account.get('username')} - </Fragment> + </React.Fragment> ); } @@ -57,3 +56,5 @@ class FollowRequest extends ImmutablePureComponent { } } + +export default injectIntl(FollowRequest); diff --git a/app/javascript/mastodon/features/notifications/components/grant_permission_button.js b/app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx index 798e4c787..5b2db48fd 100644 --- a/app/javascript/mastodon/features/notifications/components/grant_permission_button.js +++ b/app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx @@ -10,7 +10,7 @@ export default class GrantPermissionButton extends React.PureComponent { render () { return ( - <button className='text-btn column-header__permission-btn' tabIndex='0' onClick={this.props.onClick}> + <button className='text-btn column-header__permission-btn' tabIndex={0} onClick={this.props.onClick}> <FormattedMessage id='notifications.grant_permission' defaultMessage='Grant permission.' /> </button> ); diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.jsx index ea2c9c0a4..f3104cee0 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.js +++ b/app/javascript/mastodon/features/notifications/components/notification.jsx @@ -33,7 +33,6 @@ const notificationForScreenReader = (intl, message, timestamp) => { return output.join(', '); }; -export default @injectIntl class Notification extends ImmutablePureComponent { static contextTypes = { @@ -61,12 +60,12 @@ class Notification extends ImmutablePureComponent { handleMoveUp = () => { const { notification, onMoveUp } = this.props; onMoveUp(notification.get('id')); - } + }; handleMoveDown = () => { const { notification, onMoveDown } = this.props; onMoveDown(notification.get('id')); - } + }; handleOpen = () => { const { notification } = this.props; @@ -76,34 +75,34 @@ class Notification extends ImmutablePureComponent { } else { this.handleOpenProfile(); } - } + }; handleOpenProfile = () => { const { notification } = this.props; this.context.router.history.push(`/@${notification.getIn(['account', 'acct'])}`); - } + }; handleMention = e => { e.preventDefault(); const { notification, onMention } = this.props; onMention(notification.get('account'), this.context.router.history); - } + }; handleHotkeyFavourite = () => { const { status } = this.props; if (status) this.props.onFavourite(status); - } + }; handleHotkeyBoost = e => { const { status } = this.props; if (status) this.props.onReblog(status, e); - } + }; handleHotkeyToggleHidden = () => { const { status } = this.props; if (status) this.props.onToggleHidden(status); - } + }; getHandlers () { return { @@ -124,7 +123,7 @@ class Notification extends ImmutablePureComponent { return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-follow focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.follow, { name: account.get('acct') }), notification.get('created_at'))}> + <div className={classNames('notification notification-follow focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.follow, { name: account.get('acct') }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='user-plus' fixedWidth /> @@ -146,7 +145,7 @@ class Notification extends ImmutablePureComponent { return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-follow-request focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage({ id: 'notification.follow_request', defaultMessage: '{name} has requested to follow you' }, { name: account.get('acct') }), notification.get('created_at'))}> + <div className={classNames('notification notification-follow-request focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage({ id: 'notification.follow_request', defaultMessage: '{name} has requested to follow you' }, { name: account.get('acct') }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='user' fixedWidth /> @@ -186,7 +185,7 @@ class Notification extends ImmutablePureComponent { return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-favourite focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.favourite, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> + <div className={classNames('notification notification-favourite focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.favourite, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='star' className='star-icon' fixedWidth /> @@ -218,7 +217,7 @@ class Notification extends ImmutablePureComponent { return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-reblog focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.reblog, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> + <div className={classNames('notification notification-reblog focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.reblog, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='retweet' fixedWidth /> @@ -246,11 +245,15 @@ class Notification extends ImmutablePureComponent { } renderStatus (notification, link) { - const { intl, unread } = this.props; + const { intl, unread, status } = this.props; + + if (!status) { + return null; + } return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-status focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.status, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> + <div className={classNames('notification notification-status focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.status, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='home' fixedWidth /> @@ -264,6 +267,7 @@ class Notification extends ImmutablePureComponent { <StatusContainer id={notification.get('status')} account={notification.get('account')} + contextType='notifications' muted withDismiss hidden={this.props.hidden} @@ -278,11 +282,15 @@ class Notification extends ImmutablePureComponent { } renderUpdate (notification, link) { - const { intl, unread } = this.props; + const { intl, unread, status } = this.props; + + if (!status) { + return null; + } return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-update focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.update, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> + <div className={classNames('notification notification-update focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.update, { name: notification.getIn(['account', 'acct']) }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='pencil' fixedWidth /> @@ -296,6 +304,7 @@ class Notification extends ImmutablePureComponent { <StatusContainer id={notification.get('status')} account={notification.get('account')} + contextType='notifications' muted withDismiss hidden={this.props.hidden} @@ -310,13 +319,17 @@ class Notification extends ImmutablePureComponent { } renderPoll (notification, account) { - const { intl, unread } = this.props; + const { intl, unread, status } = this.props; const ownPoll = me === account.get('id'); const message = ownPoll ? intl.formatMessage(messages.ownPoll) : intl.formatMessage(messages.poll); + if (!status) { + return null; + } + return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-poll focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, message, notification.get('created_at'))}> + <div className={classNames('notification notification-poll focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, message, notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='tasks' fixedWidth /> @@ -334,6 +347,7 @@ class Notification extends ImmutablePureComponent { <StatusContainer id={notification.get('status')} account={account} + contextType='notifications' muted withDismiss hidden={this.props.hidden} @@ -352,7 +366,7 @@ class Notification extends ImmutablePureComponent { return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-admin-sign-up focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.adminSignUp, { name: account.get('acct') }), notification.get('created_at'))}> + <div className={classNames('notification notification-admin-sign-up focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.adminSignUp, { name: account.get('acct') }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='user-plus' fixedWidth /> @@ -382,7 +396,7 @@ class Notification extends ImmutablePureComponent { return ( <HotKeys handlers={this.getHandlers()}> - <div className={classNames('notification notification-admin-report focusable', { unread })} tabIndex='0' aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.adminReport, { name: account.get('acct'), target: notification.getIn(['report', 'target_account', 'acct']) }), notification.get('created_at'))}> + <div className={classNames('notification notification-admin-report focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.adminReport, { name: account.get('acct'), target: notification.getIn(['report', 'target_account', 'acct']) }), notification.get('created_at'))}> <div className='notification__message'> <div className='notification__favourite-icon-wrapper'> <Icon id='flag' fixedWidth /> @@ -432,3 +446,5 @@ class Notification extends ImmutablePureComponent { } } + +export default injectIntl(Notification); diff --git a/app/javascript/mastodon/features/notifications/components/notifications_permission_banner.js b/app/javascript/mastodon/features/notifications/components/notifications_permission_banner.jsx index df9b7fb1b..c54137e60 100644 --- a/app/javascript/mastodon/features/notifications/components/notifications_permission_banner.js +++ b/app/javascript/mastodon/features/notifications/components/notifications_permission_banner.jsx @@ -12,8 +12,6 @@ const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, }); -export default @connect() -@injectIntl class NotificationsPermissionBanner extends React.PureComponent { static propTypes = { @@ -23,11 +21,11 @@ class NotificationsPermissionBanner extends React.PureComponent { handleClick = () => { this.props.dispatch(requestBrowserPermission()); - } + }; handleClose = () => { this.props.dispatch(changeSetting(['notifications', 'dismissPermissionBanner'], true)); - } + }; render () { const { intl } = this.props; @@ -46,3 +44,5 @@ class NotificationsPermissionBanner extends React.PureComponent { } } + +export default connect()(injectIntl(NotificationsPermissionBanner)); diff --git a/app/javascript/mastodon/features/notifications/components/report.js b/app/javascript/mastodon/features/notifications/components/report.jsx index 3ce3eb9d3..4663b2359 100644 --- a/app/javascript/mastodon/features/notifications/components/report.js +++ b/app/javascript/mastodon/features/notifications/components/report.jsx @@ -13,7 +13,6 @@ const messages = defineMessages({ violation: { id: 'report_notification.categories.violation', defaultMessage: 'Rule violation' }, }); -export default @injectIntl class Report extends ImmutablePureComponent { static propTypes = { @@ -60,3 +59,5 @@ class Report extends ImmutablePureComponent { } } + +export default injectIntl(Report); diff --git a/app/javascript/mastodon/features/notifications/components/setting_toggle.js b/app/javascript/mastodon/features/notifications/components/setting_toggle.jsx index c4c8bffbe..c979e4383 100644 --- a/app/javascript/mastodon/features/notifications/components/setting_toggle.js +++ b/app/javascript/mastodon/features/notifications/components/setting_toggle.jsx @@ -13,11 +13,11 @@ export default class SettingToggle extends React.PureComponent { onChange: PropTypes.func.isRequired, defaultValue: PropTypes.bool, disabled: PropTypes.bool, - } + }; onChange = ({ target }) => { this.props.onChange(this.props.settingPath, target.checked); - } + }; render () { const { prefix, settings, settingPath, label, defaultValue, disabled } = this.props; diff --git a/app/javascript/mastodon/features/notifications/containers/column_settings_container.js b/app/javascript/mastodon/features/notifications/containers/column_settings_container.js index 9a70bd4f3..515afaca9 100644 --- a/app/javascript/mastodon/features/notifications/containers/column_settings_container.js +++ b/app/javascript/mastodon/features/notifications/containers/column_settings_container.js @@ -2,8 +2,7 @@ import { connect } from 'react-redux'; import { defineMessages, injectIntl } from 'react-intl'; import ColumnSettings from '../components/column_settings'; import { changeSetting } from '../../../actions/settings'; -import { setFilter } from '../../../actions/notifications'; -import { clearNotifications, requestBrowserPermission } from '../../../actions/notifications'; +import { setFilter, clearNotifications, requestBrowserPermission } from '../../../actions/notifications'; import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications'; import { openModal } from '../../../actions/modal'; import { showAlert } from '../../../actions/alerts'; diff --git a/app/javascript/mastodon/features/notifications/containers/notification_container.js b/app/javascript/mastodon/features/notifications/containers/notification_container.js index 8bd5b3d78..8c5688acb 100644 --- a/app/javascript/mastodon/features/notifications/containers/notification_container.js +++ b/app/javascript/mastodon/features/notifications/containers/notification_container.js @@ -24,7 +24,7 @@ const makeMapStateToProps = () => { const notification = getNotification(state, props.notification, props.accountId); return { notification: notification, - status: notification.get('status') ? getStatus(state, { id: notification.get('status') }) : null, + status: notification.get('status') ? getStatus(state, { id: notification.get('status'), contextType: 'notifications' }) : null, report: notification.get('report') ? getReport(state, notification.get('report'), notification.getIn(['report', 'target_account', 'id'])) : null, }; }; diff --git a/app/javascript/mastodon/features/notifications/index.js b/app/javascript/mastodon/features/notifications/index.jsx index 826a7e9ad..bb8852abf 100644 --- a/app/javascript/mastodon/features/notifications/index.js +++ b/app/javascript/mastodon/features/notifications/index.jsx @@ -67,8 +67,6 @@ const mapStateToProps = state => ({ needsNotificationPermission: state.getIn(['settings', 'notifications', 'alerts']).includes(true) && state.getIn(['notifications', 'browserSupport']) && state.getIn(['notifications', 'browserPermission']) === 'default' && !state.getIn(['settings', 'notifications', 'dismissPermissionBanner']), }); -export default @connect(mapStateToProps) -@injectIntl class Notifications extends React.PureComponent { static contextTypes = { @@ -136,30 +134,30 @@ class Notifications extends React.PureComponent { } else { dispatch(addColumn('NOTIFICATIONS', {})); } - } + }; handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); - } + }; handleHeaderClick = () => { this.column.scrollTop(); - } + }; setColumnRef = c => { this.column = c; - } + }; handleMoveUp = id => { const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1; this._selectChild(elementIndex, true); - } + }; handleMoveDown = id => { const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1; this._selectChild(elementIndex, false); - } + }; _selectChild (index, align_top) { const container = this.column.node; @@ -288,3 +286,5 @@ class Notifications extends React.PureComponent { } } + +export default connect(mapStateToProps)(injectIntl(Notifications)); |