diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-27 15:31:09 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-27 15:46:49 +0100 |
commit | 68f6c87a27bd3616644368154914a683001f8aa6 (patch) | |
tree | d1db9fb50f9973b697c43c5c06935a5c5a9ff819 /client/src/app/shared | |
parent | acfa2e300defbf79994f49b2062ec6bece5ad1a9 (diff) | |
download | PeerTube-68f6c87a27bd3616644368154914a683001f8aa6.tar.gz PeerTube-68f6c87a27bd3616644368154914a683001f8aa6.tar.zst PeerTube-68f6c87a27bd3616644368154914a683001f8aa6.zip |
Various front optimizations
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/shared-main/date/date-toggle.component.html | 5 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/date/date-toggle.component.ts | 16 |
2 files changed, 11 insertions, 10 deletions
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 @@ | |||
1 | <span | 1 | <span |
2 | class="date-toggle" | 2 | class="date-toggle" |
3 | [title]="getTitle()" | 3 | [title]="getTitle()" |
4 | [innerHtml]="getContent()" | ||
5 | (click)="toggle()" | 4 | (click)="toggle()" |
6 | ></span> | 5 | > |
6 | {{ getContent() }} | ||
7 | </span> | ||
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' | |||
7 | templateUrl: './date-toggle.component.html', | 7 | templateUrl: './date-toggle.component.html', |
8 | styleUrls: [ './date-toggle.component.scss' ] | 8 | styleUrls: [ './date-toggle.component.scss' ] |
9 | }) | 9 | }) |
10 | export class DateToggleComponent implements OnInit, OnChanges { | 10 | export class DateToggleComponent implements OnChanges { |
11 | @Input() date: Date | 11 | @Input() date: Date |
12 | @Input() toggled = false | 12 | @Input() toggled = false |
13 | 13 | ||
@@ -19,10 +19,6 @@ export class DateToggleComponent implements OnInit, OnChanges { | |||
19 | private fromNowPipe: FromNowPipe | 19 | private fromNowPipe: FromNowPipe |
20 | ) { } | 20 | ) { } |
21 | 21 | ||
22 | ngOnInit () { | ||
23 | this.updateDates() | ||
24 | } | ||
25 | |||
26 | ngOnChanges () { | 22 | ngOnChanges () { |
27 | this.updateDates() | 23 | this.updateDates() |
28 | } | 24 | } |
@@ -32,15 +28,19 @@ export class DateToggleComponent implements OnInit, OnChanges { | |||
32 | } | 28 | } |
33 | 29 | ||
34 | getTitle () { | 30 | getTitle () { |
35 | return this.toggled ? this.dateRelative : this.dateAbsolute | 31 | return this.toggled |
32 | ? this.dateRelative | ||
33 | : this.dateAbsolute | ||
36 | } | 34 | } |
37 | 35 | ||
38 | getContent () { | 36 | getContent () { |
39 | return this.toggled ? this.dateAbsolute : this.dateRelative | 37 | return this.toggled |
38 | ? this.dateAbsolute | ||
39 | : this.dateRelative | ||
40 | } | 40 | } |
41 | 41 | ||
42 | private updateDates () { | 42 | private updateDates () { |
43 | this.dateRelative = this.fromNowPipe.transform(this.date) | 43 | this.dateRelative = this.fromNowPipe.transform(this.date) |
44 | this.dateAbsolute = this.datePipe.transform(this.date, 'long') | 44 | this.dateAbsolute = this.date.toLocaleDateString() |
45 | } | 45 | } |
46 | } | 46 | } |