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
+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])