Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz committed Nov 4, 2024
1 parent dd39388 commit 8ca9802
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ qx.Class.define("osparc.notification.Notifications", {

getNotifications: function() {
return this.__notifications;
}
},

markAllAsRead: function() {
this.__notifications.forEach(notification => {
if (notification.isRead() === false) {
osparc.notification.Notifications.markAsRead(notification);
}
});
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ qx.Class.define("osparc.notification.NotificationsButton", {
},

__updateButton: function() {
const notifications = osparc.notification.Notifications.getInstance().getNotifications();
const notificationManager = osparc.notification.Notifications.getInstance();
const notifications = notificationManager.getNotifications();
notifications.forEach(notification => notification.addListener("changeRead", () => this.__updateButton(), this));

const nUnreadNotifications = notifications.filter(notification => notification.getRead() === false).length;
Expand Down Expand Up @@ -117,6 +118,10 @@ qx.Class.define("osparc.notification.NotificationsButton", {
// Show the container
this.__notificationsContainer.show();

// mark all notifications as read
const notificationManager = osparc.notification.Notifications.getInstance();
notificationManager.markAllAsRead();

// Add listener for taps outside the container to hide it
document.addEventListener("mousedown", this.__onTapOutside.bind(this), true);
},
Expand Down

0 comments on commit 8ca9802

Please sign in to comment.