Skip to content

Commit

Permalink
fix: updates notifications store only after closing the dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed May 23, 2024
1 parent b245987 commit 418ccde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
function onVisibilityChange({ detail }: CustomEvent): void {
if (detail.visible) {
toggleObserve()
} else {
notificationsManager.updateAllSubscriptionsAndNotifications()
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,18 @@ export class NotificationsManager {
}

markAsRead(notificationIds: string[], topic: string): void {
this.notifyClient?.markNotificationsAsRead({ notificationIds, topic })
this.notificationsPerSubscription.update((state) => {
state[topic] = state[topic].map((notification) => {
if (notificationIds.includes(notification.id)) {
notification.isRead = true
}
return notification
})
return state
})
void this.notifyClient?.markNotificationsAsRead({ notificationIds, topic })
}

async updateAllSubscriptionsAndNotifications(): Promise<void> {
if (!this.notifyClient) {
return
}

const activeSubscriptions = Object.values(this.notifyClient.getActiveSubscriptions())
this.updateSubscriptionsPerAddress(activeSubscriptions)

await this.updateNotificationsForSubscriptions(activeSubscriptions)
}
}

Expand Down

0 comments on commit 418ccde

Please sign in to comment.