From 68f6c87a27bd3616644368154914a683001f8aa6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Nov 2020 15:31:09 +0100 Subject: Various front optimizations --- .../shared/shared-main/date/date-toggle.component.html | 5 +++-- .../app/shared/shared-main/date/date-toggle.component.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'client/src/app/shared/shared-main/date') diff --git a/client/src/app/shared/shared-main/date/date-toggle.component.html b/client/src/app/shared/shared-main/date/date-toggle.component.html index ebd4ce442..14b6e7d7a 100644 --- a/client/src/app/shared/shared-main/date/date-toggle.component.html +++ b/client/src/app/shared/shared-main/date/date-toggle.component.html @@ -1,6 +1,7 @@ +> + {{ getContent() }} + diff --git a/client/src/app/shared/shared-main/date/date-toggle.component.ts b/client/src/app/shared/shared-main/date/date-toggle.component.ts index bedf0ba4e..53f25f0ad 100644 --- a/client/src/app/shared/shared-main/date/date-toggle.component.ts +++ b/client/src/app/shared/shared-main/date/date-toggle.component.ts @@ -7,7 +7,7 @@ import { FromNowPipe } from '../angular/from-now.pipe' templateUrl: './date-toggle.component.html', styleUrls: [ './date-toggle.component.scss' ] }) -export class DateToggleComponent implements OnInit, OnChanges { +export class DateToggleComponent implements OnChanges { @Input() date: Date @Input() toggled = false @@ -19,10 +19,6 @@ export class DateToggleComponent implements OnInit, OnChanges { private fromNowPipe: FromNowPipe ) { } - ngOnInit () { - this.updateDates() - } - ngOnChanges () { this.updateDates() } @@ -32,15 +28,19 @@ export class DateToggleComponent implements OnInit, OnChanges { } getTitle () { - return this.toggled ? this.dateRelative : this.dateAbsolute + return this.toggled + ? this.dateRelative + : this.dateAbsolute } getContent () { - return this.toggled ? this.dateAbsolute : this.dateRelative + return this.toggled + ? this.dateAbsolute + : this.dateRelative } private updateDates () { this.dateRelative = this.fromNowPipe.transform(this.date) - this.dateAbsolute = this.datePipe.transform(this.date, 'long') + this.dateAbsolute = this.date.toLocaleDateString() } } -- cgit v1.2.3