From d370fccf925dd2c906608a0c461241c382960310 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 26 Aug 2018 17:53:26 +0200 Subject: [PATCH] Add aria-label to notifications (#8460) Fix #8192 --- app/javascript/mastodon/components/status.js | 4 +-- .../notifications/components/notification.js | 28 +++++++++++++++---- .../mastodon/reducers/notifications.js | 1 + 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 9809a9a329..7090c12d01 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -18,12 +18,12 @@ import classNames from 'classnames'; // to use the progress bar to show download progress import Bundle from '../features/ui/components/bundle'; -export const textForScreenReader = (intl, status, rebloggedByText = false, expanded = false) => { +export const textForScreenReader = (intl, status, rebloggedByText = false) => { const displayName = status.getIn(['account', 'display_name']); const values = [ displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName, - status.get('spoiler_text') && !expanded ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length), + status.get('spoiler_text') && status.get('hidden') ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length), intl.formatDate(status.get('created_at'), { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' }), status.getIn(['account', 'acct']), ]; diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.js index f58224a8b4..07fec84b24 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.js +++ b/app/javascript/mastodon/features/notifications/components/notification.js @@ -3,11 +3,20 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import StatusContainer from '../../../containers/status_container'; import AccountContainer from '../../../containers/account_container'; -import { FormattedMessage } from 'react-intl'; +import { injectIntl, FormattedMessage } from 'react-intl'; import Permalink from '../../../components/permalink'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { HotKeys } from 'react-hotkeys'; +const notificationForScreenReader = (intl, message, timestamp) => { + const output = [message]; + + output.push(intl.formatDate(timestamp, { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' })); + + return output.join(', '); +}; + +@injectIntl export default class Notification extends ImmutablePureComponent { static contextTypes = { @@ -20,6 +29,7 @@ export default class Notification extends ImmutablePureComponent { onMoveUp: PropTypes.func.isRequired, onMoveDown: PropTypes.func.isRequired, onMention: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired, }; handleMoveUp = () => { @@ -65,10 +75,12 @@ export default class Notification extends ImmutablePureComponent { }; } - renderFollow (account, link) { + renderFollow (notification, account, link) { + const { intl } = this.props; + return ( -
+
@@ -97,9 +109,11 @@ export default class Notification extends ImmutablePureComponent { } renderFavourite (notification, link) { + const { intl } = this.props; + return ( -
+
@@ -114,9 +128,11 @@ export default class Notification extends ImmutablePureComponent { } renderReblog (notification, link) { + const { intl } = this.props; + return ( -
+
@@ -138,7 +154,7 @@ export default class Notification extends ImmutablePureComponent { switch(notification.get('type')) { case 'follow': - return this.renderFollow(account, link); + return this.renderFollow(notification, account, link); case 'mention': return this.renderMention(notification); case 'favourite': diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js index 84d4fc6988..0b29f19fa4 100644 --- a/app/javascript/mastodon/reducers/notifications.js +++ b/app/javascript/mastodon/reducers/notifications.js @@ -26,6 +26,7 @@ const notificationToMap = notification => ImmutableMap({ id: notification.id, type: notification.type, account: notification.account.id, + created_at: notification.created_at, status: notification.status ? notification.status.id : null, });