1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 08:56:38 +02:00

feat: JS Notification extender (#3974)

* feat: JS `Notification` extender

* fix
This commit is contained in:
Sami Mazouz
2024-05-14 21:10:07 +01:00
committed by GitHub
parent d273b1920f
commit 29ede5aa27
12 changed files with 53 additions and 22 deletions

View File

@@ -0,0 +1,25 @@
import IExtender, { IExtensionModule } from './IExtender';
import type Component from '../Component';
import ForumApplication from '../../forum/ForumApplication';
import type Application from '../Application';
import type { NewComponent } from '../Application';
export default class Notification implements IExtender {
private notificationComponents: Record<string, new () => Component> = {};
/**
* Register a new notification component type.
*
* @param name The name of the notification type.
* @param component The component class to render the notification.
*/
add(name: string, component: NewComponent<any>): Notification {
this.notificationComponents[name] = component;
return this;
}
extend(app: Application, extension: IExtensionModule): void {
Object.assign((app as unknown as ForumApplication).notificationComponents, this.notificationComponents);
}
}

View File

@@ -3,6 +3,7 @@ import PostTypes from './PostTypes';
import Routes from './Routes';
import Store from './Store';
import Search from './Search';
import Notification from './Notification';
const extenders = {
Model,
@@ -10,6 +11,7 @@ const extenders = {
Routes,
Store,
Search,
Notification,
};
export default extenders;