Skip to content

Commit 872b08d

Browse files
committed
remove saving of notification and fixed dismiss action
1 parent f629a6a commit 872b08d

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

src/lib/notificationManager.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class NotificationManager {
1414
if (instance) {
1515
return instance;
1616
}
17-
this.notifications = this.loadNotifications();
17+
this.notifications = [];
1818
instance = this;
1919
}
2020

@@ -62,23 +62,6 @@ export default class NotificationManager {
6262
});
6363
}
6464

65-
loadNotifications() {
66-
try {
67-
const notifications =
68-
JSON.parse(localStorage.getItem("notifications")) || [];
69-
return notifications.map((n) => ({
70-
...n,
71-
time: new Date(n.time),
72-
}));
73-
} catch {
74-
return [];
75-
}
76-
}
77-
78-
saveNotifications() {
79-
localStorage.setItem("notifications", JSON.stringify(this.notifications));
80-
}
81-
8265
renderNotifications() {
8366
const container = sidebarApps
8467
.get("notification")
@@ -112,7 +95,6 @@ export default class NotificationManager {
11295
if (index > -1) {
11396
notificationElement.remove();
11497
this.notifications.splice(index, 1);
115-
this.saveNotifications();
11698
this.renderNotifications();
11799
}
118100
}
@@ -141,9 +123,12 @@ export default class NotificationManager {
141123
</div>
142124
`;
143125
if (notification.action) {
144-
element.addEventListener("click", () =>
145-
notification.action(notification),
146-
);
126+
element.addEventListener("click", (e) => {
127+
if (e.target.closest(".action-button")) {
128+
return;
129+
}
130+
notification.action(notification);
131+
});
147132
}
148133
return element;
149134
}
@@ -187,8 +172,6 @@ export default class NotificationManager {
187172
this.notifications.pop();
188173
}
189174

190-
this.saveNotifications();
191-
192175
this.renderNotifications();
193176

194177
// show toast notification
@@ -240,7 +223,6 @@ export default class NotificationManager {
240223

241224
clearAll() {
242225
this.notifications = [];
243-
this.saveNotifications();
244226
this.renderNotifications();
245227
if (this.timeUpdateInterval) {
246228
clearInterval(this.timeUpdateInterval);

www/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164

165165
<title>Acode</title>
166166
<!--styles-->
167+
<link rel="stylesheet" href="./css/build/218.css">
167168
<link rel="stylesheet" href="./css/build/32.css">
168169
<link rel="stylesheet" href="./css/build/383.css">
169170
<link rel="stylesheet" href="./css/build/53.css">

0 commit comments

Comments
 (0)