mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-22 00:47:29 -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 {
|
class NotificationHelper {
|
||||||
private electronNotification: Map<number, ElectronNotification>;
|
private electronNotification: Map<number, ElectronNotification>;
|
||||||
|
private activeElectronNotification: Map<string, ElectronNotification>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.electronNotification = new Map<number, ElectronNotification>();
|
this.electronNotification = new Map<number, ElectronNotification>();
|
||||||
|
this.activeElectronNotification = new Map<string, ElectronNotification>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,8 +24,19 @@ class NotificationHelper {
|
|||||||
if (options.isElectronNotification) {
|
if (options.isElectronNotification) {
|
||||||
// MacOS: Electron notification only supports static image path
|
// MacOS: Electron notification only supports static image path
|
||||||
options.icon = this.getIcon(options);
|
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);
|
const electronToast = new ElectronNotification(options, this.notificationCallback);
|
||||||
this.electronNotification.set(options.id, electronToast);
|
this.electronNotification.set(options.id, electronToast);
|
||||||
|
this.activeElectronNotification.set(options.tag, electronToast);
|
||||||
electronToast.show();
|
electronToast.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user