From 3512e44a977d82146b8e828693a2adab746e0bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Tue, 23 Nov 2021 13:56:41 +0100 Subject: [PATCH] Bug fix na agenda presenting events --- src/app/pages/agenda/agenda.page.ts | 39 ++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 07ae8a76f..5bf088374 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -161,6 +161,7 @@ export class AgendaPage implements OnInit { dropdownScrollWeal = false CalendarStore = CalendarStore listToPresent + array = [] constructor( private alertCtrl: AlertController, @@ -232,6 +233,8 @@ export class AgendaPage implements OnInit { ngOnInit() { + this.getFromDB(); + const pathname = window.location.pathname let realoadCounter = 0 this.router.events.forEach((event) => { @@ -240,14 +243,14 @@ export class AgendaPage implements OnInit { this.segment = "Combinado"; } if (realoadCounter != 0) { - this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); + //this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); } realoadCounter++; } }); this.backgroundservice.registerBackService('Online', () => { - this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); + //this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); }); window.onresize = (event) => { @@ -514,6 +517,7 @@ export class AgendaPage implements OnInit { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + console.log('check list to present data', this.listToPresent); this.myCal.update(); this.myCal.loadEvents(); @@ -540,13 +544,17 @@ export class AgendaPage implements OnInit { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + console.log('check list to present data', this.listToPresent); this.myCal.update(); this.myCal.loadEvents(); this.showLoader = false; this.showTimeline = true; - }).finally(() => { + }).catch((error) => { + this.getFromDB() + }) + .finally(() => { this.showLoader = false; }) @@ -567,6 +575,7 @@ export class AgendaPage implements OnInit { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + console.log('check list to present data', this.listToPresent); this.myCal.update(); this.myCal.loadEvents(); @@ -603,6 +612,7 @@ export class AgendaPage implements OnInit { this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + console.log('check list to present data', this.listToPresent); this.myCal.update(); this.myCal.loadEvents(); @@ -614,7 +624,10 @@ export class AgendaPage implements OnInit { } - }).finally(() => { + }).catch((error) => { + this.getFromDB() + }) + .finally(() => { counter++; if (counter == 2) { this.showLoader = false; @@ -633,6 +646,8 @@ export class AgendaPage implements OnInit { this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + console.log('check list to present data', this.listToPresent); + this.myCal.update(); this.myCal.loadEvents(); @@ -644,7 +659,10 @@ export class AgendaPage implements OnInit { this.showLoader = false; } - }).finally(() => { + }).catch((error) => { + this.getFromDB() + }) + .finally(() => { counter++; if (counter == 2) { this.showLoader = false; @@ -674,6 +692,7 @@ export class AgendaPage implements OnInit { this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) + console.log('check list to present data', this.listToPresent); this.myCal.update(); this.myCal.loadEvents(); @@ -685,7 +704,10 @@ export class AgendaPage implements OnInit { this.showLoader = false; } - }).finally(() => { + }).catch((error) => { + this.getFromDB() + }) + .finally(() => { if (counter == 1 || this.loggeduser.Profile == 'PR') { this.showLoader = false; } @@ -697,7 +719,6 @@ export class AgendaPage implements OnInit { } trasnformData(response,profile) { - let array = [] response.forEach(element => { let event = { startTime: new Date(element.StartDate), @@ -708,10 +729,10 @@ export class AgendaPage implements OnInit { profile: profile, id: element.EventId, } - array.push(event) + this.array.push(event) }); - this.listToPresent = array; + this.listToPresent = this.array; console.log('LIST TO PRESET', this.listToPresent) }