Pull title logic into its own method

This commit is contained in:
Daniel Waterworth 2019-06-07 09:40:42 +01:00 committed by Robin Ward
parent d83147d137
commit 305562bf66

View File

@ -124,6 +124,18 @@ export const DefaultNotificationItem =
return iconNode(`notification.${infoKey}`);
},
title(notificationName, data) {
if (notificationName) {
if (notificationName === "custom") {
return data.title ? I18n.t(data.title) : "";
} else {
return I18n.t(`notifications.titles.${notificationName}`);
}
} else {
return "";
}
},
html(attrs) {
const notificationType = attrs.notification_type;
const lookup = this.site.get("notificationLookup");
@ -133,17 +145,7 @@ export const DefaultNotificationItem =
let text = emojiUnescape(this.text(notificationType, notificationName));
let icon = this.icon(notificationName, data);
let title;
if (notificationName) {
if (notificationName === "custom") {
title = data.title ? I18n.t(data.title) : "";
} else {
title = I18n.t(`notifications.titles.${notificationName}`);
}
} else {
title = "";
}
const title = this.title(notificationName, data);
// We can use a `<p>` tag here once other languages have fixed their HTML
// translations.