check notification and inactivity

This commit is contained in:
Peter Maquiran
2023-09-28 09:02:15 +01:00
parent b46d179dfe
commit 8de8a35bfc
11 changed files with 93 additions and 60 deletions
+24 -7
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, NgZone } from '@angular/core';
import { StorageService } from '../services/storage.service';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
@@ -13,6 +13,7 @@ export class NotificationHolderService {
constructor(
private storageService: StorageService,
private zone: NgZone,
) {
try {
@@ -106,19 +107,32 @@ export class NotificationHolderService {
}
}
if(this.notificationExist(notificationObject)) {
if(!this.notificationExist(notificationObject)) {
this._notificationList.push(notificationObject)
this.reverse()
this.save()
this.zone.run(()=>{
this.reverse()
this.save()
})
} else {
console.log('duplicate', notification, this._notificationList)
}
}
notificationExist(notificationObject) {
return this._notificationList.find(item => {
const notification = this._notificationList.find(item => {
return item.id === notificationObject.id;
});
if(notification?.id) {
return true
} else {
return false
}
}
@@ -136,8 +150,11 @@ export class NotificationHolderService {
return e.index != notification.index
})
this.reverse()
this.save()
this.zone.run(()=>{
this.save()
this.reverse()
})
}
}