Pass data to description to prevent duplication

This commit is contained in:
Daniel Waterworth 2019-06-07 10:40:46 +01:00 committed by Robin Ward
parent 8c349101c5
commit 70e27641eb
4 changed files with 5 additions and 8 deletions

View File

@ -10,7 +10,7 @@ createWidgetFrom(DefaultNotificationItem, "custom-notification-item", {
text(notificationName, data) {
const username = formatUsername(data.display_username);
const description = this.description();
const description = this.description(data);
return I18n.t(data.message, { description, username });
},

View File

@ -58,8 +58,7 @@ export const DefaultNotificationItem =
}
},
description() {
const data = this.attrs.data;
description(data) {
const badgeName = data.badge_name;
if (badgeName) {
return escapeExpression(badgeName);
@ -81,7 +80,7 @@ export const DefaultNotificationItem =
text(notificationName, data) {
const username = formatUsername(data.display_username);
const description = this.description();
const description = this.description(data);
return I18n.t(`notifications.${notificationName}`, { description, username });
},

View File

@ -14,9 +14,7 @@ createWidgetFrom(DefaultNotificationItem, "liked-consolidated-notification-item"
);
},
description() {
const data = this.attrs.data;
description(data) {
const description =
I18n.t("notifications.liked_consolidated_description", {
count: parseInt(data.count)

View File

@ -5,7 +5,7 @@ import { formatUsername } from "discourse/lib/utilities";
createWidgetFrom(DefaultNotificationItem, "liked-notification-item", {
text(notificationName, data) {
const username = formatUsername(data.display_username);
const description = this.description();
const description = this.description(data);
if (data.count > 1) {
const count = data.count - 2;