11import React from 'react' ;
2- import PropTypes from 'prop-types' ;
32import ImmutablePropTypes from 'react-immutable-proptypes' ;
4- import StatusContainer from '../../../containers/status_container' ;
5- import AccountContainer from '../../../containers/account_container' ;
6- import { injectIntl , FormattedMessage } from 'react-intl' ;
7- import Permalink from '../../../components/permalink' ;
8- import ImmutablePureComponent from 'react-immutable-pure-component' ;
3+ import { injectIntl , FormattedMessage , defineMessages } from 'react-intl' ;
94import { HotKeys } from 'react-hotkeys' ;
5+ import PropTypes from 'prop-types' ;
6+ import ImmutablePureComponent from 'react-immutable-pure-component' ;
7+ import { me } from 'mastodon/initial_state' ;
8+ import StatusContainer from 'mastodon/containers/status_container' ;
9+ import AccountContainer from 'mastodon/containers/account_container' ;
1010import Icon from 'mastodon/components/icon' ;
11+ import Permalink from 'mastodon/components/permalink' ;
12+
13+ const messages = defineMessages ( {
14+ favourite : { id : 'notification.favourite' , defaultMessage : '{name} favourited your status' } ,
15+ follow : { id : 'notification.follow' , defaultMessage : '{name} followed you' } ,
16+ ownPoll : { id : 'notification.own_poll' , defaultMessage : 'Your poll has ended' } ,
17+ poll : { id : 'notification.poll' , defaultMessage : 'A poll you have voted in has ended' } ,
18+ reblog : { id : 'notification.reblog' , defaultMessage : '{name} boosted your status' } ,
19+ } ) ;
1120
1221const notificationForScreenReader = ( intl , message , timestamp ) => {
1322 const output = [ message ] ;
@@ -107,7 +116,7 @@ class Notification extends ImmutablePureComponent {
107116
108117 return (
109118 < HotKeys handlers = { this . getHandlers ( ) } >
110- < div className = 'notification notification-follow focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( { id : 'notification .follow' , defaultMessage : '{name} followed you' } , { name : account . get ( 'acct' ) } ) , notification . get ( 'created_at' ) ) } >
119+ < div className = 'notification notification-follow focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( messages . follow , { name : account . get ( 'acct' ) } ) , notification . get ( 'created_at' ) ) } >
111120 < div className = 'notification__message' >
112121 < div className = 'notification__favourite-icon-wrapper' >
113122 < Icon id = 'user-plus' fixedWidth />
@@ -146,7 +155,7 @@ class Notification extends ImmutablePureComponent {
146155
147156 return (
148157 < HotKeys handlers = { this . getHandlers ( ) } >
149- < div className = 'notification notification-favourite focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( { id : 'notification .favourite' , defaultMessage : '{name} favourited your status' } , { name : notification . getIn ( [ 'account' , 'acct' ] ) } ) , notification . get ( 'created_at' ) ) } >
158+ < div className = 'notification notification-favourite focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( messages . favourite , { name : notification . getIn ( [ 'account' , 'acct' ] ) } ) , notification . get ( 'created_at' ) ) } >
150159 < div className = 'notification__message' >
151160 < div className = 'notification__favourite-icon-wrapper' >
152161 < Icon id = 'star' className = 'star-icon' fixedWidth />
@@ -178,7 +187,7 @@ class Notification extends ImmutablePureComponent {
178187
179188 return (
180189 < HotKeys handlers = { this . getHandlers ( ) } >
181- < div className = 'notification notification-reblog focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( { id : 'notification .reblog' , defaultMessage : '{name} boosted your status' } , { name : notification . getIn ( [ 'account' , 'acct' ] ) } ) , notification . get ( 'created_at' ) ) } >
190+ < div className = 'notification notification-reblog focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( messages . reblog , { name : notification . getIn ( [ 'account' , 'acct' ] ) } ) , notification . get ( 'created_at' ) ) } >
182191 < div className = 'notification__message' >
183192 < div className = 'notification__favourite-icon-wrapper' >
184193 < Icon id = 'retweet' fixedWidth />
@@ -205,25 +214,31 @@ class Notification extends ImmutablePureComponent {
205214 ) ;
206215 }
207216
208- renderPoll ( notification ) {
217+ renderPoll ( notification , account ) {
209218 const { intl } = this . props ;
219+ const ownPoll = me === account . get ( 'id' ) ;
220+ const message = ownPoll ? intl . formatMessage ( messages . ownPoll ) : intl . formatMessage ( messages . poll ) ;
210221
211222 return (
212223 < HotKeys handlers = { this . getHandlers ( ) } >
213- < div className = 'notification notification-poll focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , intl . formatMessage ( { id : 'notification.poll' , defaultMessage : 'A poll you have voted in has ended' } ) , notification . get ( 'created_at' ) ) } >
224+ < div className = 'notification notification-poll focusable' tabIndex = '0' aria-label = { notificationForScreenReader ( intl , message , notification . get ( 'created_at' ) ) } >
214225 < div className = 'notification__message' >
215226 < div className = 'notification__favourite-icon-wrapper' >
216227 < Icon id = 'tasks' fixedWidth />
217228 </ div >
218229
219230 < span title = { notification . get ( 'created_at' ) } >
220- < FormattedMessage id = 'notification.poll' defaultMessage = 'A poll you have voted in has ended' />
231+ { ownPoll ? (
232+ < FormattedMessage id = 'notification.ownPoll' defaultMessage = 'Your poll has ended' />
233+ ) : (
234+ < FormattedMessage id = 'notification.poll' defaultMessage = 'A poll you have voted in has ended' />
235+ ) }
221236 </ span >
222237 </ div >
223238
224239 < StatusContainer
225240 id = { notification . get ( 'status' ) }
226- account = { notification . get ( ' account' ) }
241+ account = { account }
227242 muted
228243 withDismiss
229244 hidden = { this . props . hidden }
@@ -253,7 +268,7 @@ class Notification extends ImmutablePureComponent {
253268 case 'reblog' :
254269 return this . renderReblog ( notification , link ) ;
255270 case 'poll' :
256- return this . renderPoll ( notification ) ;
271+ return this . renderPoll ( notification , account ) ;
257272 }
258273
259274 return null ;
0 commit comments