@@ -2,9 +2,13 @@ import type { INotificationTray } from "src/ghosttext-adaptor"
22import type { MessageId } from "src/util"
33import type { ManifestInfo } from "."
44
5+ /** Wraps the Notification API */
56export class NotificationTray implements INotificationTray {
67 static isSingleton = true
78
9+ /** Maximum number of notifications to show simultaneously */
10+ private readonly slotCount = 5
11+ private lastId = 0
812 private title : string | undefined
913
1014 constructor (
@@ -13,7 +17,8 @@ export class NotificationTray implements INotificationTray {
1317 ) { }
1418
1519 async showNotification ( iconUrl : string , messageId : MessageId ) : Promise < void > {
16- await this . messenger . notifications . create ( this . makeNotification ( iconUrl , messageId ) )
20+ const opts = this . makeNotification ( iconUrl , messageId )
21+ await this . messenger . notifications . create ( this . makeId ( ) , opts )
1722 }
1823
1924 private makeNotification ( iconUrl : string , messageId : MessageId ) : messenger . notifications . CreateNotificationOptions {
@@ -25,4 +30,9 @@ export class NotificationTray implements INotificationTray {
2530 message : this . messenger . i18n . getMessage ( messageId ) ,
2631 }
2732 }
33+
34+ private makeId ( ) : string {
35+ this . lastId = ( this . lastId + 1 ) % this . slotCount
36+ return `NotificationTray-${ this . lastId } `
37+ }
2838}
0 commit comments