From 8921348bbb49ff80c2d93c5424b7242b4f9973fe Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 14 Feb 2022 10:54:06 +0100 Subject: [PATCH] empty date list after emptying calendar list --- src/app/core/services/poll.service.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 0d40e11c..82f9751f 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -733,18 +733,21 @@ export class PollService implements Resolve { */ convertCalendarToText() { console.log('this.dateChoiceList', this.dateChoiceList); - // if(!this.dateChoiceList.length){ - // return []; - // } - let converted = []; - for (let someDate of this.calendar) { - converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); - } - this.dateChoiceList = converted.sort((first: any, second: any) => { - return first.date_object - second.date_object; - }); - return converted; + if (this.calendar && this.calendar.length) { + let converted = []; + for (let someDate of this.calendar) { + converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); + } + + this.dateChoiceList = converted.sort((first: any, second: any) => { + return first.date_object - second.date_object; + }); + return converted; + } else { + this.dateChoiceList = []; + } + return this.dateChoiceList; } /**