]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/date/date-toggle.component.ts
Various front optimizations
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / date / date-toggle.component.ts
index bedf0ba4e5193bba56a873784b1b45c0e211a726..53f25f0ad3b48bd8e8b199b0872a395236c4de36 100644 (file)
@@ -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()
   }
 }