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 6c96b9fe879..8b9cb7d779f 100644 --- a/app/assets/javascripts/discourse/widgets/default-notification-item.js.es6 +++ b/app/assets/javascripts/discourse/widgets/default-notification-item.js.es6 @@ -59,16 +59,6 @@ export const DefaultNotificationItem = return userPath(data.display_username); } - if (attrs.notification_type === notificationTypes.liked_consolidated) { - return userPath( - `${this.attrs.username || - this.currentUser - .username}/notifications/likes-received?acting_username=${ - data.display_username - }` - ); - } - if (data.group_id) { return userPath(data.username + "/messages/group/" + data.group_name); } @@ -90,18 +80,7 @@ export const DefaultNotificationItem = return this.attrs.fancy_title; } - let description; - - if ( - this.attrs.notification_type === - this.site.notification_types.liked_consolidated - ) { - description = I18n.t("notifications.liked_consolidated_description", { - count: parseInt(data.count) - }); - } else { - description = data.topic_title; - } + const description = data.topic_title; return Ember.isEmpty(description) ? "" : escapeExpression(description); }, 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 new file mode 100644 index 00000000000..324b5d697d3 --- /dev/null +++ b/app/assets/javascripts/discourse/widgets/liked-consolidated-notification-item.js.es6 @@ -0,0 +1,30 @@ +import { createWidgetFrom } from "discourse/widgets/widget"; +import { DefaultNotificationItem } from "discourse/widgets/default-notification-item"; +import { escapeExpression } from "discourse/lib/utilities"; +import { userPath } from "discourse/lib/url"; + +createWidgetFrom(DefaultNotificationItem, "liked-consolidated-notification-item", { + url() { + const attrs = this.attrs; + const data = attrs.data; + + return userPath( + `${this.attrs.username || + this.currentUser + .username}/notifications/likes-received?acting_username=${ + data.display_username + }` + ); + }, + + description() { + const data = this.attrs.data; + + const description = + I18n.t("notifications.liked_consolidated_description", { + count: parseInt(data.count) + }); + + return Ember.isEmpty(description) ? "" : escapeExpression(description); + } +});