| 78 | }, |
| 79 | |
| 80 | async showAlert (alert, sender) { |
| 81 | // If module already has an open alert close it |
| 82 | if (this.alerts[sender.name]) { |
| 83 | this.hideAlert(sender, false); |
| 84 | } |
| 85 | |
| 86 | // Add overlay |
| 87 | if (!Object.keys(this.alerts).length) { |
| 88 | this.toggleBlur(true); |
| 89 | } |
| 90 | |
| 91 | const message = await this.renderMessage(alert.templateName || "alert", alert); |
| 92 | |
| 93 | // Store alert in this.alerts |
| 94 | this.alerts[sender.name] = new NotificationFx({ |
| 95 | message, |
| 96 | effect: this.config.alert_effect, |
| 97 | ttl: alert.timer, |
| 98 | onClose: () => this.hideAlert(sender), |
| 99 | al_no: "ns-alert" |
| 100 | }); |
| 101 | |
| 102 | // Show alert |
| 103 | this.alerts[sender.name].show(); |
| 104 | |
| 105 | // Add timer to dismiss alert and overlay |
| 106 | if (alert.timer) { |
| 107 | setTimeout(() => { |
| 108 | this.hideAlert(sender); |
| 109 | }, alert.timer); |
| 110 | } |
| 111 | }, |
| 112 | |
| 113 | hideAlert (sender, close = true) { |
| 114 | // Dismiss alert and remove from this.alerts |