Refactor: デスクトップ通知用のデフォルトメッセージのコード (#833)
* Refactor: デスクトップ通知用のデフォルトメッセージのコード * Fix lint
This commit is contained in:
parent
f93dbec9d3
commit
1b4edeefae
5 changed files with 24 additions and 27 deletions
|
@ -81,24 +81,21 @@ export const NOTIFICATIONS_FOR_REQUEST_EXPAND_REQUEST = 'NOTIFICATIONS_FOR_REQUE
|
||||||
export const NOTIFICATIONS_FOR_REQUEST_EXPAND_SUCCESS = 'NOTIFICATIONS_FOR_REQUEST_EXPAND_SUCCESS';
|
export const NOTIFICATIONS_FOR_REQUEST_EXPAND_SUCCESS = 'NOTIFICATIONS_FOR_REQUEST_EXPAND_SUCCESS';
|
||||||
export const NOTIFICATIONS_FOR_REQUEST_EXPAND_FAIL = 'NOTIFICATIONS_FOR_REQUEST_EXPAND_FAIL';
|
export const NOTIFICATIONS_FOR_REQUEST_EXPAND_FAIL = 'NOTIFICATIONS_FOR_REQUEST_EXPAND_FAIL';
|
||||||
|
|
||||||
const DEFAULT_NOTIFICATION_MESSAGES = {
|
const messages = defineMessages({
|
||||||
'notification.admin.report': '{name} reported {target}',
|
// mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
|
||||||
'notification.admin.sign_up': '{name} signed up',
|
|
||||||
'notification.emoji_reaction': '{name} reacted your post with emoji',
|
|
||||||
'notification.favourite': '{name} favorited your post',
|
|
||||||
'notification.follow': '{name} followed you',
|
|
||||||
'notification.list_status': '{name} post is added to {listName}',
|
|
||||||
'notification.mention': 'Mention',
|
|
||||||
'notification.poll': 'A poll you voted in has ended',
|
|
||||||
'notification.reblog': '{name} boosted your post',
|
|
||||||
'notification.status': '{name} just posted',
|
|
||||||
'notification.status_reference': '{name} quoted your post',
|
|
||||||
'notification.update': '{name} edited a post',
|
|
||||||
};
|
|
||||||
|
|
||||||
defineMessages({
|
|
||||||
mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
|
|
||||||
group: { id: 'notifications.group', defaultMessage: '{count} notifications' },
|
group: { id: 'notifications.group', defaultMessage: '{count} notifications' },
|
||||||
|
'message_admin.report': { id: 'notification.admin.report', defaultMessage: '{name} reported {target}' },
|
||||||
|
'message_admin.sign_up': { id: 'notification.admin.sign_up', defaultMessage: '{name} signed up' },
|
||||||
|
message_emoji_reaction: { id: 'notification.emoji_reaction', defaultMessage: '{name} reacted your post with emoji' },
|
||||||
|
message_favourite: { id: 'notification.favourite', defaultMessage: '{name} favorited your post' },
|
||||||
|
message_follow: { id: 'notification.follow', defaultMessage: '{name} followed you' },
|
||||||
|
message_list_status: { id: 'notification.list_status', defaultMessage: '{name} post is added to {listName}' },
|
||||||
|
message_mention: { id: 'notification.mention', defaultMessage: 'Mention' },
|
||||||
|
message_poll: { id: 'notification.poll', defaultMessage: 'A poll you voted in has ended' },
|
||||||
|
message_reblog: { id: 'notification.reblog', defaultMessage: '{name} boosted your post' },
|
||||||
|
message_status: { id: 'notification.status', defaultMessage: '{name} just posted' },
|
||||||
|
message_status_reference: { id: 'notification.status_reference', defaultMessage: '{name} quoted your post' },
|
||||||
|
message_update: { id: 'notification.update', defaultMessage: '{name} edited a post' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchRelatedRelationships = (dispatch, notifications) => {
|
const fetchRelatedRelationships = (dispatch, notifications) => {
|
||||||
|
@ -176,7 +173,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
|
|
||||||
// Desktop notifications
|
// Desktop notifications
|
||||||
if (typeof window.Notification !== 'undefined' && showAlert && !filtered) {
|
if (typeof window.Notification !== 'undefined' && showAlert && !filtered) {
|
||||||
const messageTemplate = intlMessages[`notification.${notification.type}`] || DEFAULT_NOTIFICATION_MESSAGES[`notification.${notification.type}`];
|
const messageTemplate = intlMessages[`notification.${notification.type}`] || messages[`message_${notification.type}`] || '[NO MESSAGE DEFINITION]';
|
||||||
const title = new IntlMessageFormat(messageTemplate, intlLocale).format({
|
const title = new IntlMessageFormat(messageTemplate, intlLocale).format({
|
||||||
name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username,
|
name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username,
|
||||||
listName: notification.list && notification.list.title,
|
listName: notification.list && notification.list.title,
|
||||||
|
|
|
@ -34,12 +34,12 @@ import { RelationshipsSeveranceEvent } from './relationships_severance_event';
|
||||||
import Report from './report';
|
import Report from './report';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
favourite: { id: 'notification.favourite', defaultMessage: '{name} favorited your status' },
|
favourite: { id: 'notification.favourite', defaultMessage: '{name} favorited your post' },
|
||||||
emojiReaction: { id: 'notification.emoji_reaction', defaultMessage: '{name} reacted your status with emoji' },
|
emojiReaction: { id: 'notification.emoji_reaction', defaultMessage: '{name} reacted your post with emoji' },
|
||||||
follow: { id: 'notification.follow', defaultMessage: '{name} followed you' },
|
follow: { id: 'notification.follow', defaultMessage: '{name} followed you' },
|
||||||
ownPoll: { id: 'notification.own_poll', defaultMessage: 'Your poll has ended' },
|
ownPoll: { id: 'notification.own_poll', defaultMessage: 'Your poll has ended' },
|
||||||
poll: { id: 'notification.poll', defaultMessage: 'A poll you voted in has ended' },
|
poll: { id: 'notification.poll', defaultMessage: 'A poll you voted in has ended' },
|
||||||
reblog: { id: 'notification.reblog', defaultMessage: '{name} boosted your status' },
|
reblog: { id: 'notification.reblog', defaultMessage: '{name} boosted your post' },
|
||||||
status: { id: 'notification.status', defaultMessage: '{name} just posted' },
|
status: { id: 'notification.status', defaultMessage: '{name} just posted' },
|
||||||
listStatus: { id: 'notification.list_status', defaultMessage: '{name} post is added to {listName}' },
|
listStatus: { id: 'notification.list_status', defaultMessage: '{name} post is added to {listName}' },
|
||||||
statusReference: { id: 'notification.status_reference', defaultMessage: '{name} quoted your post' },
|
statusReference: { id: 'notification.status_reference', defaultMessage: '{name} quoted your post' },
|
||||||
|
@ -207,7 +207,7 @@ class Notification extends ImmutablePureComponent {
|
||||||
<Icon id='star' icon={StarIcon} className='star-icon' />
|
<Icon id='star' icon={StarIcon} className='star-icon' />
|
||||||
|
|
||||||
<span title={notification.get('created_at')}>
|
<span title={notification.get('created_at')}>
|
||||||
<FormattedMessage id='notification.favourite' defaultMessage='{name} favorited your status' values={{ name: link }} />
|
<FormattedMessage id='notification.favourite' defaultMessage='{name} favorited your post' values={{ name: link }} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ class Notification extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span title={notification.get('created_at')}>
|
<span title={notification.get('created_at')}>
|
||||||
<FormattedMessage id='notification.emoji_reaction' defaultMessage='{name} reacted your status with emoji' values={{ name: link }} />
|
<FormattedMessage id='notification.emoji_reaction' defaultMessage='{name} reacted your post with emoji' values={{ name: link }} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ class Notification extends ImmutablePureComponent {
|
||||||
<Icon id='retweet' icon={RepeatIcon} />
|
<Icon id='retweet' icon={RepeatIcon} />
|
||||||
|
|
||||||
<span title={notification.get('created_at')}>
|
<span title={notification.get('created_at')}>
|
||||||
<FormattedMessage id='notification.reblog' defaultMessage='{name} boosted your status' values={{ name: link }} />
|
<FormattedMessage id='notification.reblog' defaultMessage='{name} boosted your post' values={{ name: link }} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ const labelRenderer: LabelRenderer = (displayedName, total, seeMoreHref) => {
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notification.emoji_reaction'
|
id='notification.emoji_reaction'
|
||||||
defaultMessage='{name} reacted your status with emoji'
|
defaultMessage='{name} reacted your post with emoji'
|
||||||
values={{ name: displayedName }}
|
values={{ name: displayedName }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,7 @@ const labelRenderer: LabelRenderer = (displayedName, total, seeMoreHref) => {
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notification.favourite'
|
id='notification.favourite'
|
||||||
defaultMessage='{name} favorited your status'
|
defaultMessage='{name} favorited your post'
|
||||||
values={{ name: displayedName }}
|
values={{ name: displayedName }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,7 @@ const labelRenderer: LabelRenderer = (displayedName, total, seeMoreHref) => {
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='notification.reblog'
|
id='notification.reblog'
|
||||||
defaultMessage='{name} boosted your status'
|
defaultMessage='{name} boosted your post'
|
||||||
values={{ name: displayedName }}
|
values={{ name: displayedName }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue