add notification and system notification

This commit is contained in:
MathieuG-P
2022-12-26 00:09:52 +01:00
parent 89ac6077be
commit ef202e33ec
11 changed files with 138 additions and 5 deletions
+19 -1
View File
@@ -1,17 +1,27 @@
import { BehaviorSubject } from "rxjs";
import { SystemNotificationOptions } from "shared/models/notification/system-notification.model";
import { I18nService } from "./i18n.service";
import { IpcService } from "./ipc.service";
export class NotificationService{
private static instance: NotificationService;
public readonly notifications$: BehaviorSubject<ResolvableNotification[]>;
public static getInstance(): NotificationService{
if(!NotificationService.instance){ NotificationService.instance = new NotificationService(); }
return NotificationService.instance;
}
public readonly notifications$: BehaviorSubject<ResolvableNotification[]>;
private readonly ipc: IpcService;
private readonly i18n: I18nService;
private constructor(){
this.ipc = IpcService.getInstance();
this.i18n = I18nService.getInstance();
this.notifications$ = new BehaviorSubject<ResolvableNotification[]>([]);
}
@@ -46,6 +56,14 @@ export class NotificationService{
return this.notify(notification);
}
public notifySystem(options: SystemNotificationOptions){
options.body = options.body && this.i18n.translate(options.body);
options.title = options.title && this.i18n.translate(options.title);
this.ipc.sendLazy<SystemNotificationOptions>("notify-system", {args: options});
}
}
export interface Notification {