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) { text(notificationName, data) {
const username = formatUsername(data.display_username); const username = formatUsername(data.display_username);
const description = this.description(); const description = this.description(data);
return I18n.t(data.message, { description, username }); return I18n.t(data.message, { description, username });
}, },

View File

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

View File

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

View File

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