duplication of notification solved

This commit is contained in:
Eudes Inácio
2023-08-03 13:04:58 +01:00
parent c96aad2136
commit a059187885
4 changed files with 25 additions and 8 deletions
+1
View File
@@ -103,6 +103,7 @@ export class ProfilePage implements OnInit {
this.DataArray = []
value.forEach((element, i) => {
console.log('Getnotifications',element, i )
let notificationObject;
if (element.notification) {
+1 -1
View File
@@ -139,7 +139,7 @@ export class LoginPage implements OnInit {
}
this.changeProfileService.runLogin();
this.getToken();
/* this.getToken(); */
SessionStore.setInativity(true);
this.goback();
+17 -1
View File
@@ -163,7 +163,23 @@ export class NotificationsService {
this.storageService.get("Notifications").then((store) => {
store.push(notification)
this.storageService.store("Notifications", store)
console.log('Store Notification ',store)
const result = store.reduce((accumulator, current) => {
let exists = accumulator.find(item => {
return item.id === current.id;
});
if(!exists) {
accumulator = accumulator.concat(current);
}
return accumulator;
}, []);
console.log(result);
this.storageService.store("Notifications", result)
}).catch((error) => {
if (!error) {
this.storageService.store("Notifications", [notification])