mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/notifications: close notification when room is read from another client
This commit is contained in:
parent
7676f21292
commit
b15db20347
2 changed files with 9 additions and 0 deletions
|
@ -158,6 +158,8 @@ export class StateStore {
|
|||
// image: ...,
|
||||
tag: rowid.toString(),
|
||||
})
|
||||
room.openNotifications.set(rowid, notif)
|
||||
notif.onclose = () => room.openNotifications.delete(rowid)
|
||||
notif.onclick = () => this.onClickNotification(room.roomID)
|
||||
if (sound) {
|
||||
// TODO play sound
|
||||
|
|
|
@ -76,6 +76,7 @@ export class RoomStateStore {
|
|||
readonly eventsByID: Map<EventID, MemDBEvent> = new Map()
|
||||
readonly timelineSub = new Subscribable()
|
||||
readonly eventSubs: Map<EventID, EventSubscribable> = new Map()
|
||||
readonly openNotifications: Map<EventRowID, Notification> = new Map()
|
||||
readonly pendingEvents: EventRowID[] = []
|
||||
paginating = false
|
||||
paginationRequestedForRow = -1
|
||||
|
@ -203,6 +204,12 @@ export class RoomStateStore {
|
|||
} else {
|
||||
this.timeline.push(...sync.timeline)
|
||||
}
|
||||
if (sync.meta.unread_notifications === 0 && sync.meta.unread_highlights === 0) {
|
||||
for (const notif of this.openNotifications.values()) {
|
||||
notif.close()
|
||||
}
|
||||
this.openNotifications.clear()
|
||||
}
|
||||
this.notifyTimelineSubscribers()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue