([show, type, name, time]: string[])
| 41 | time: number | undefined; |
| 42 | |
| 43 | constructor([show, type, name, time]: string[]) { |
| 44 | super(); |
| 45 | |
| 46 | this.hasPermission = false; |
| 47 | |
| 48 | // First check if HTML5 notifications are available |
| 49 | if (!('Notification' in window)) { |
| 50 | console.warn('Notifications are not supported in this platform.'); |
| 51 | } |
| 52 | |
| 53 | // Finally check if the given notification exists in the object |
| 54 | if (typeof Notify.notifications(name) !== 'undefined') { |
| 55 | this.notification = Object.assign({}, Notify.notifications(name)); |
| 56 | |
| 57 | if (typeof time !== 'undefined') { |
| 58 | if (!isNaN(Number(time))) { |
| 59 | this.time = parseInt(time); |
| 60 | } else { |
| 61 | FancyError.show('action:notification:invalid_time', { |
| 62 | time: time, |
| 63 | statement: `<code class='language=javascript'>"${this._statement}"</code>`, |
| 64 | label: this.engine.state('label'), |
| 65 | step: this.engine.state('step') |
| 66 | }); |
| 67 | } |
| 68 | } |
| 69 | } else { |
| 70 | FancyError.show('action:notification:not_found', { |
| 71 | name: name, |
| 72 | availableNotifications: Object.keys(Notify.notifications()), |
| 73 | label: this.engine.state('label'), |
| 74 | step: this.engine.state('step') |
| 75 | }); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | override async willApply(): Promise<void> { |
| 80 | if (!this.notification) { |
nothing calls this directly
no test coverage detected