* Handles the closing of a notification by extracting its options and * broadcasting a `NOTIFICATION_CLOSE` message. * * This is typically called when a notification is dismissed by the user * or closed programmatically, and it relays that information to clients * listening for servic
(notification: Notification, action: string)
| 488 | * @param action - The action string associated with the close event, if any (usually an empty string). |
| 489 | */ |
| 490 | private async handleClose(notification: Notification, action: string): Promise<void> { |
| 491 | const options: {-readonly [K in keyof Notification]?: Notification[K]} = {}; |
| 492 | NOTIFICATION_OPTION_NAMES.filter((name) => name in notification).forEach( |
| 493 | (name) => (options[name] = notification[name]), |
| 494 | ); |
| 495 | |
| 496 | await this.broadcast({ |
| 497 | type: 'NOTIFICATION_CLOSE', |
| 498 | data: {action, notification: options}, |
| 499 | }); |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Handles changes to the push subscription by capturing the old and new |