mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
add notification and system notification
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user