From 5ddef69c487c363003a544ae2407113e99ec445e Mon Sep 17 00:00:00 2001 From: Leon Hoppe Date: Thu, 7 Nov 2024 20:44:31 +0100 Subject: [PATCH] created change listener for current date on analysis page --- src/app/analysis/analysis.page.html | 2 +- src/app/analysis/analysis.page.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/analysis/analysis.page.html b/src/app/analysis/analysis.page.html index 6b24924..acc434b 100644 --- a/src/app/analysis/analysis.page.html +++ b/src/app/analysis/analysis.page.html @@ -19,7 +19,7 @@ - + diff --git a/src/app/analysis/analysis.page.ts b/src/app/analysis/analysis.page.ts index 2ea46e3..d464e7c 100644 --- a/src/app/analysis/analysis.page.ts +++ b/src/app/analysis/analysis.page.ts @@ -49,12 +49,26 @@ export class AnalysisPage { @ViewChild('chart') chartRef: ElementRef; private chart: any; + private changeListener: any; + constructor(private time: TimeService) { addIcons({briefcase, pizza, card}) } ionViewDidEnter() { this.updateCurrentData(); + + let lastDate: any = undefined; + this.changeListener = setInterval(() => { + if (this.currentDate != lastDate) { + lastDate = this.currentDate; + this.updateCurrentData(); + } + }, 200) + } + + ionViewDidLeave() { + clearInterval(this.changeListener); } public updateCurrentData() {