clear storage and add group

This commit is contained in:
Lorito Tiago
2023-10-11 16:20:42 +01:00
5 changed files with 172 additions and 141 deletions
+18 -9
View File
@@ -18,7 +18,7 @@ export class NotificationHolderService {
try {
this.restore()
} catch(error) {}
} catch (error) { }
}
@@ -29,11 +29,11 @@ export class NotificationHolderService {
restore() {
this.storageService.get("Notifications").then((store) => {
if(Array.isArray(store)) {
if (Array.isArray(store)) {
this._notificationList = store
this.reverse()
}
}).catch((error) => {})
}).catch((error) => { })
}
save() {
@@ -107,10 +107,10 @@ export class NotificationHolderService {
}
}
if(!this.notificationExist(notificationObject)) {
if (!this.notificationExist(notificationObject)) {
this._notificationList.push(notificationObject)
this.zone.run(()=>{
this.zone.run(() => {
this.reverse()
this.save()
})
@@ -124,11 +124,11 @@ export class NotificationHolderService {
notificationExist(notificationObject) {
const notification = this._notificationList.find(item => {
const notification = this._notificationList.find(item => {
return item.id === notificationObject.id;
});
if(notification?.id) {
if (notification?.id) {
return true
} else {
return false
@@ -146,12 +146,21 @@ export class NotificationHolderService {
}
removeNotification(notification) {
this._notificationList = this._notificationList.filter( (e) => {
this._notificationList = this._notificationList.filter((e) => {
return e.index != notification.index
})
this.zone.run(()=>{
this.zone.run(() => {
this.save()
this.reverse()
})
}
clear() {
this._notificationList = []
this.zone.run(() => {
this.save()
this.reverse()
})