Implement notification excerpts

This commit is contained in:
Toby Zerner 2015-08-21 09:54:57 +09:30
parent 6606f416af
commit 1930fcdd92
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import Notification from 'flarum/components/Notification'; import Notification from 'flarum/components/Notification';
import username from 'flarum/helpers/username'; import username from 'flarum/helpers/username';
import punctuate from 'flarum/helpers/punctuate'; import punctuate from 'flarum/helpers/punctuate';
import { truncate } from 'flarum/utils/string';
export default class PostMentionedNotification extends Notification { export default class PostMentionedNotification extends Notification {
icon() { icon() {
@ -18,7 +19,6 @@ export default class PostMentionedNotification extends Notification {
content() { content() {
const notification = this.props.notification; const notification = this.props.notification;
const post = notification.subject();
const auc = notification.additionalUnreadCount(); const auc = notification.additionalUnreadCount();
const user = notification.sender(); const user = notification.sender();
@ -27,8 +27,11 @@ export default class PostMentionedNotification extends Notification {
username: auc ? punctuate([ username: auc ? punctuate([
username(user), username(user),
app.trans('mentions.others', {count: auc}) app.trans('mentions.others', {count: auc})
]) : undefined, ]) : undefined
number: post.number()
}); });
} }
excerpt() {
return truncate(this.props.notification.subject().contentPlain(), 100);
}
} }

View File

@ -1,6 +1,6 @@
mentions: mentions:
reply_to_post: "Reply to #{number}" reply_to_post: "Reply to #{number}"
post_mentioned_notification: "{username} replied to your post #{number}" post_mentioned_notification: "{username} replied to your post"
others: "{count} others" others: "{count} others"
user_mentioned_notification: "{username} mentioned you" user_mentioned_notification: "{username} mentioned you"
post_mentioned_by: "{users} replied to this." post_mentioned_by: "{users} replied to this."