Skip to content

Commit

Permalink
remove saving of notification and fixed dismiss action
Browse files Browse the repository at this point in the history
  • Loading branch information
bajrangCoder committed Nov 23, 2024
1 parent f629a6a commit 872b08d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
32 changes: 7 additions & 25 deletions src/lib/notificationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class NotificationManager {
if (instance) {
return instance;
}
this.notifications = this.loadNotifications();
this.notifications = [];
instance = this;
}

Expand Down Expand Up @@ -62,23 +62,6 @@ export default class NotificationManager {
});
}

loadNotifications() {
try {
const notifications =
JSON.parse(localStorage.getItem("notifications")) || [];
return notifications.map((n) => ({
...n,
time: new Date(n.time),
}));
} catch {
return [];
}
}

saveNotifications() {
localStorage.setItem("notifications", JSON.stringify(this.notifications));
}

renderNotifications() {
const container = sidebarApps
.get("notification")
Expand Down Expand Up @@ -112,7 +95,6 @@ export default class NotificationManager {
if (index > -1) {
notificationElement.remove();
this.notifications.splice(index, 1);
this.saveNotifications();
this.renderNotifications();
}
}
Expand Down Expand Up @@ -141,9 +123,12 @@ export default class NotificationManager {
</div>
`;
if (notification.action) {
element.addEventListener("click", () =>
notification.action(notification),
);
element.addEventListener("click", (e) => {
if (e.target.closest(".action-button")) {
return;
}
notification.action(notification);
});
}
return element;
}
Expand Down Expand Up @@ -187,8 +172,6 @@ export default class NotificationManager {
this.notifications.pop();
}

this.saveNotifications();

this.renderNotifications();

// show toast notification
Expand Down Expand Up @@ -240,7 +223,6 @@ export default class NotificationManager {

clearAll() {
this.notifications = [];
this.saveNotifications();
this.renderNotifications();
if (this.timeUpdateInterval) {
clearInterval(this.timeUpdateInterval);
Expand Down
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@

<title>Acode</title>
<!--styles-->
<link rel="stylesheet" href="./css/build/218.css">
<link rel="stylesheet" href="./css/build/32.css">
<link rel="stylesheet" href="./css/build/383.css">
<link rel="stylesheet" href="./css/build/53.css">
Expand Down

0 comments on commit 872b08d

Please sign in to comment.