()
| 396 | class Notifications { |
| 397 | |
| 398 | constructor() { |
| 399 | // Check if the browser supports notifications |
| 400 | if (!('Notification' in window)) return; |
| 401 | |
| 402 | // Check whether notification permissions have already been granted |
| 403 | if (Notification.permission !== 'granted') { |
| 404 | this.$button = $('notification'); |
| 405 | this.$button.removeAttribute('hidden'); |
| 406 | this.$button.addEventListener('click', e => this._requestPermission()); |
| 407 | } |
| 408 | Events.on('text-received', e => this._messageNotification(e.detail.text)); |
| 409 | Events.on('file-received', e => this._downloadNotification(e.detail.name)); |
| 410 | } |
| 411 | |
| 412 | _requestPermission() { |
| 413 | Notification.requestPermission(permission => { |
nothing calls this directly
no test coverage detected