diff --git a/framework/core/js/src/forum/components/Notification.tsx b/framework/core/js/src/forum/components/Notification.tsx index a0acdac33..c91ff8df5 100644 --- a/framework/core/js/src/forum/components/Notification.tsx +++ b/framework/core/js/src/forum/components/Notification.tsx @@ -13,6 +13,8 @@ export interface INotificationAttrs extends ComponentAttrs { notification: NotificationModel; } +// TODO [Flarum 2.0]: Remove `?.` from abstract function calls. + /** * The `Notification` component abstract displays a single notification. * Subclasses should implement the `icon`, `href`, and `content` methods. @@ -20,7 +22,7 @@ export interface INotificationAttrs extends ComponentAttrs { export default abstract class Notification extends Component { view(vnode: Mithril.Vnode) { const notification = this.attrs.notification; - const href = this.href(); + const href = this.href?.() ?? ''; const fromUser = notification.fromUser(); @@ -32,9 +34,9 @@ export default abstract class Notification {avatar(fromUser || null)} - {icon(this.icon(), { className: 'Notification-icon' })} + {icon(this.icon?.(), { className: 'Notification-icon' })} - {this.content()} + {this.content?.()} {humanTime(notification.createdAt())} @@ -51,7 +53,7 @@ export default abstract class Notification )} -
{this.excerpt()}
+
{this.excerpt?.()}
); }