From 70e27641eb810851001824c76c4d851a7e426019 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Fri, 7 Jun 2019 10:40:46 +0100 Subject: [PATCH] Pass data to description to prevent duplication --- .../discourse/widgets/custom-notification-item.js.es6 | 2 +- .../discourse/widgets/default-notification-item.js.es6 | 5 ++--- .../widgets/liked-consolidated-notification-item.js.es6 | 4 +--- .../discourse/widgets/liked-notification-item.js.es6 | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/custom-notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/custom-notification-item.js.es6 index 75bac91f55d..8ebff6692fe 100644 --- a/app/assets/javascripts/discourse/widgets/custom-notification-item.js.es6 +++ b/app/assets/javascripts/discourse/widgets/custom-notification-item.js.es6 @@ -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 }); }, diff --git a/app/assets/javascripts/discourse/widgets/default-notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/default-notification-item.js.es6 index aa179beef32..a48899f186f 100644 --- a/app/assets/javascripts/discourse/widgets/default-notification-item.js.es6 +++ b/app/assets/javascripts/discourse/widgets/default-notification-item.js.es6 @@ -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 }); }, diff --git a/app/assets/javascripts/discourse/widgets/liked-consolidated-notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/liked-consolidated-notification-item.js.es6 index a23e31c3863..9c5f7d9ce1d 100644 --- a/app/assets/javascripts/discourse/widgets/liked-consolidated-notification-item.js.es6 +++ b/app/assets/javascripts/discourse/widgets/liked-consolidated-notification-item.js.es6 @@ -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) diff --git a/app/assets/javascripts/discourse/widgets/liked-notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/liked-notification-item.js.es6 index aba3e0f50aa..e24762edd46 100644 --- a/app/assets/javascripts/discourse/widgets/liked-notification-item.js.es6 +++ b/app/assets/javascripts/discourse/widgets/liked-notification-item.js.es6 @@ -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;