mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
fix: SDA-2811 - Replace native electron notification with same tag (#1163)
This commit is contained in:
parent
420dee0d48
commit
6fdb80857f
@ -7,9 +7,11 @@ import { ElectronNotification } from './electron-notification';
|
||||
|
||||
class NotificationHelper {
|
||||
private electronNotification: Map<number, ElectronNotification>;
|
||||
private activeElectronNotification: Map<string, ElectronNotification>;
|
||||
|
||||
constructor() {
|
||||
this.electronNotification = new Map<number, ElectronNotification>();
|
||||
this.activeElectronNotification = new Map<string, ElectronNotification>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,8 +24,19 @@ class NotificationHelper {
|
||||
if (options.isElectronNotification) {
|
||||
// MacOS: Electron notification only supports static image path
|
||||
options.icon = this.getIcon(options);
|
||||
|
||||
// This is replace notification with same tag
|
||||
if (this.activeElectronNotification.has(options.tag)) {
|
||||
const electronNotification = this.activeElectronNotification.get(options.tag);
|
||||
if (electronNotification) {
|
||||
electronNotification.close();
|
||||
}
|
||||
this.activeElectronNotification.delete(options.tag);
|
||||
}
|
||||
|
||||
const electronToast = new ElectronNotification(options, this.notificationCallback);
|
||||
this.electronNotification.set(options.id, electronToast);
|
||||
this.activeElectronNotification.set(options.tag, electronToast);
|
||||
electronToast.show();
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user