diff --git a/config.xml b/config.xml index 97d2fb38d..7b18d7926 100644 --- a/config.xml +++ b/config.xml @@ -3,7 +3,7 @@ gabinete digital An awesome Ionic/Cordova app. Ionic Framework Team - + diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index 944d2eb15..0dbb39fe9 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -42,26 +42,48 @@ export class ProfilePage implements OnInit { } ngOnInit() { + this.storageservice.get("Notifications").then((value) => { + console.log("Init get store", value) var data = JSON.parse(value); - data.forEach((element, i) => { + console.log("Init store parse", data) + data.forEach((element,i) => { console.log("ARaaAA", element) - var payload = JSON.parse(element.payload) - let notificationObject = { - index: i, - alert: element.alert, - Service: payload.Service, - Object: payload.Object, - IdObject: payload.IdObject, - FolderId: payload.FolderId, - desc: payload.desc, - dateInit: payload.dateInit, - dateEnd: payload.dateEnd, - Location: payload.Location, - TypeAgenda: payload.TypeAgenda, - Status: payload.Status + let notificationObject; + if(element.payload){ + var payload = JSON.parse(element.payload) + notificationObject = { + index: i, + alert: element.alert, + Service: payload.Service, + Object: payload.Object, + IdObject: payload.IdObject, + FolderId: payload.FolderId, + desc: payload.desc, + dateInit: payload.dateInit, + dateEnd: payload.dateEnd, + Location: payload.Location, + TypeAgenda: payload.TypeAgenda, + Status: payload.Status + } + } else { + notificationObject = { + index: i, + alert: element.alert, + Service: element.Service, + Object: element.Object, + IdObject: element.IdObject, + FolderId: element.FolderId, + desc: element.desc, + dateInit: element.dateInit, + dateEnd: element.dateEnd, + Location: element.Location, + TypeAgenda: element.TypeAgenda, + Status: element.Status + } } + this.DataArray.push(notificationObject) }); @@ -69,6 +91,8 @@ export class ProfilePage implements OnInit { console.log("Notificaaa", this.notificationdata) }) console.log("Notificaaa", this.notificationdata) + + } @@ -124,16 +148,21 @@ export class ProfilePage implements OnInit { this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital'])); } - const indexx = this.notificationdata.indexOf(index, 0); - if (indexx > -1) { - this.notificationdata.splice(index, 1); - console.log('This notificatio', this.notificationdata); - } + this.deleteNotification(index); + + + } + + deleteNotification(index){ + console.log("Delete notification first stata", this.notificationdata) + this.notificationdata = this.notificationdata.filter(item=>item.index !=index ); - this.notificationservice.removeDepartment(index); - console.log('This notificatio 2', this.notificationdata); - - + this.storageservice.store("Notifications",JSON.stringify(this.notificationdata)).then(() =>{ + this.storageservice.get("Notifications").then((value) =>{ + console.log("notfication state", value, ) + }); + }); + console.log("Delete notification last stata", this.notificationdata) } diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index d253a06ed..906b4cc32 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -195,7 +195,7 @@ export class NotificationsService { var notificationReceived = (message) => { //this.jsonstore.createCollection('Notifications',message); this.DataArray.push(message) - console.log("On ReceiveNotification", message) + console.log("On ReceiveNotification", this.DataArray) this.storageService.store("Notifications",JSON.stringify(this.DataArray)) console.log(message);