Pull liked consolidated notification behaviour into its own class

This commit is contained in:
Daniel Waterworth 2019-06-07 08:57:01 +01:00 committed by Robin Ward
parent 42143a874e
commit 7c52ba1431
2 changed files with 31 additions and 22 deletions

View File

@ -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);
},

View File

@ -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);
}
});