diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-13 10:52:17 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-01-13 10:52:17 +0100 |
commit | 0e4ca570fa33105456f0e4650342374c1658d5f4 (patch) | |
tree | fd454210839d07534dc70c30e7b254b2e587902d /client/src/app/shared/shared-main/account/actor-avatar-info.component.ts | |
parent | d95bc7029012c9f28144fd58948962c49910a1ae (diff) | |
download | PeerTube-0e4ca570fa33105456f0e4650342374c1658d5f4.tar.gz PeerTube-0e4ca570fa33105456f0e4650342374c1658d5f4.tar.zst PeerTube-0e4ca570fa33105456f0e4650342374c1658d5f4.zip |
Avatar info component optimizations
Diffstat (limited to 'client/src/app/shared/shared-main/account/actor-avatar-info.component.ts')
-rw-r--r-- | client/src/app/shared/shared-main/account/actor-avatar-info.component.ts | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts b/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts index 451bbbba3..b459c591f 100644 --- a/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts +++ b/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' |
2 | import { Notifier, ServerService } from '@app/core' | 2 | import { Notifier, ServerService } from '@app/core' |
3 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | ||
3 | import { getBytes } from '@root-helpers/bytes' | 4 | import { getBytes } from '@root-helpers/bytes' |
4 | import { ServerConfig } from '@shared/models' | ||
5 | import { VideoChannel } from '../video-channel/video-channel.model' | ||
6 | import { Account } from '../account/account.model' | 5 | import { Account } from '../account/account.model' |
7 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | 6 | import { VideoChannel } from '../video-channel/video-channel.model' |
8 | import { Actor } from './actor.model' | 7 | import { Actor } from './actor.model' |
9 | 8 | ||
10 | @Component({ | 9 | @Component({ |
@@ -21,8 +20,11 @@ export class ActorAvatarInfoComponent implements OnInit, OnChanges { | |||
21 | @Output() avatarChange = new EventEmitter<FormData>() | 20 | @Output() avatarChange = new EventEmitter<FormData>() |
22 | @Output() avatarDelete = new EventEmitter<void>() | 21 | @Output() avatarDelete = new EventEmitter<void>() |
23 | 22 | ||
23 | avatarFormat = '' | ||
24 | maxAvatarSize = 0 | ||
25 | avatarExtensions = '' | ||
26 | |||
24 | private avatarUrl: string | 27 | private avatarUrl: string |
25 | private serverConfig: ServerConfig | ||
26 | 28 | ||
27 | constructor ( | 29 | constructor ( |
28 | private serverService: ServerService, | 30 | private serverService: ServerService, |
@@ -30,9 +32,14 @@ export class ActorAvatarInfoComponent implements OnInit, OnChanges { | |||
30 | ) { } | 32 | ) { } |
31 | 33 | ||
32 | ngOnInit (): void { | 34 | ngOnInit (): void { |
33 | this.serverConfig = this.serverService.getTmpConfig() | ||
34 | this.serverService.getConfig() | 35 | this.serverService.getConfig() |
35 | .subscribe(config => this.serverConfig = config) | 36 | .subscribe(config => { |
37 | this.maxAvatarSize = config.avatar.file.size.max | ||
38 | this.avatarExtensions = config.avatar.file.extensions.join(', ') | ||
39 | |||
40 | this.avatarFormat = `${$localize`max size`}: 192*192px, ` + | ||
41 | `${getBytes(this.maxAvatarSize)} ${$localize`extensions`}: ${this.avatarExtensions}` | ||
42 | }) | ||
36 | } | 43 | } |
37 | 44 | ||
38 | ngOnChanges (changes: SimpleChanges) { | 45 | ngOnChanges (changes: SimpleChanges) { |
@@ -60,23 +67,7 @@ export class ActorAvatarInfoComponent implements OnInit, OnChanges { | |||
60 | this.avatarDelete.emit() | 67 | this.avatarDelete.emit() |
61 | } | 68 | } |
62 | 69 | ||
63 | get maxAvatarSize () { | 70 | hasAvatar () { |
64 | return this.serverConfig.avatar.file.size.max | ||
65 | } | ||
66 | |||
67 | get maxAvatarSizeInBytes () { | ||
68 | return getBytes(this.maxAvatarSize) | ||
69 | } | ||
70 | |||
71 | get avatarExtensions () { | ||
72 | return this.serverConfig.avatar.file.extensions.join(', ') | ||
73 | } | ||
74 | |||
75 | get avatarFormat () { | ||
76 | return `${$localize`max size`}: 192*192px, ${this.maxAvatarSizeInBytes} ${$localize`extensions`}: ${this.avatarExtensions}` | ||
77 | } | ||
78 | |||
79 | get hasAvatar () { | ||
80 | return !!this.avatarUrl | 71 | return !!this.avatarUrl |
81 | } | 72 | } |
82 | } | 73 | } |