mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 14:03:39 +08:00
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.
This commit is contained in:
parent
cdf0cd3ecd
commit
04a75b1cb3
|
@ -12,8 +12,16 @@ createWidget("large-notification-item", {
|
|||
},
|
||||
|
||||
html(attrs) {
|
||||
const notificationName =
|
||||
this.site.notificationLookup[attrs.notification_type];
|
||||
|
||||
const widgetNames = [
|
||||
`${notificationName.replace(/_/g, '-')}-notification-item`,
|
||||
"default-notification-item"
|
||||
];
|
||||
|
||||
return [
|
||||
this.attach("default-notification-item", attrs),
|
||||
this.attach(widgetNames, attrs),
|
||||
h("span.time", dateNode(attrs.created_at))
|
||||
];
|
||||
}
|
||||
|
|
|
@ -88,9 +88,19 @@ export default createWidget("user-notifications", {
|
|||
if (state.loading) {
|
||||
result.push(h("div.spinner-container", h("div.spinner")));
|
||||
} else if (state.notifications.length) {
|
||||
const notificationItems = state.notifications.map(n =>
|
||||
this.attach("default-notification-item", n)
|
||||
);
|
||||
const notificationItems =
|
||||
state.notifications.map(attrs => {
|
||||
|
||||
const notificationName =
|
||||
this.site.notificationLookup[attrs.notification_type];
|
||||
|
||||
const widgetNames = [
|
||||
`${notificationName.replace(/_/g, '-')}-notification-item`,
|
||||
"default-notification-item"
|
||||
];
|
||||
|
||||
return this.attach(widgetNames, attrs);
|
||||
});
|
||||
|
||||
result.push(h("hr"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user