This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
Daniel Waterworth 04a75b1cb3 Change the way notification items are created
Look for the specialised version first, before falling back to the
default. This allows the behaviour to be customised based on the type of
notification.
2019-06-26 09:01:25 -04:00

41 lines
1.0 KiB
JavaScript

import { createWidget } from "discourse/widgets/widget";
import { h } from "virtual-dom";
import { dateNode } from "discourse/helpers/node";
createWidget("large-notification-item", {
buildClasses(attrs) {
const result = ["item", "notification", "large-notification"];
if (!attrs.get("read")) {
result.push("unread");
}
return result;
},
html(attrs) {
const notificationName =
this.site.notificationLookup[attrs.notification_type];
const widgetNames = [
`${notificationName.replace(/_/g, '-')}-notification-item`,
"default-notification-item"
];
return [
this.attach(widgetNames, attrs),
h("span.time", dateNode(attrs.created_at))
];
}
});
export default createWidget("user-notifications-large", {
html(attrs) {
const notifications = attrs.notifications;
const username = notifications.findArgs.username;
return notifications.map(n => {
n.username = username;
return this.attach("large-notification-item", n);
});
}
});