diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:31:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:40:59 +0100 |
commit | ba430d7516bc5b1324b60571ba7594460969b7fb (patch) | |
tree | df5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/+my-account/shared | |
parent | 5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff) | |
download | PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip |
Lazy load static objects
Diffstat (limited to 'client/src/app/+my-account/shared')
-rw-r--r-- | client/src/app/+my-account/shared/actor-avatar-info.component.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/client/src/app/+my-account/shared/actor-avatar-info.component.ts b/client/src/app/+my-account/shared/actor-avatar-info.component.ts index 0289a66c3..101dfa556 100644 --- a/client/src/app/+my-account/shared/actor-avatar-info.component.ts +++ b/client/src/app/+my-account/shared/actor-avatar-info.component.ts | |||
@@ -1,26 +1,35 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { ServerService } from '../../core/server' | 2 | import { ServerService } from '../../core/server' |
3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
4 | import { Account } from '@app/shared/account/account.model' | 4 | import { Account } from '@app/shared/account/account.model' |
5 | import { Notifier } from '@app/core' | 5 | import { Notifier } from '@app/core' |
6 | import { ServerConfig } from '@shared/models' | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-actor-avatar-info', | 9 | selector: 'my-actor-avatar-info', |
9 | templateUrl: './actor-avatar-info.component.html', | 10 | templateUrl: './actor-avatar-info.component.html', |
10 | styleUrls: [ './actor-avatar-info.component.scss' ] | 11 | styleUrls: [ './actor-avatar-info.component.scss' ] |
11 | }) | 12 | }) |
12 | export class ActorAvatarInfoComponent { | 13 | export class ActorAvatarInfoComponent implements OnInit { |
13 | @ViewChild('avatarfileInput', { static: false }) avatarfileInput: ElementRef<HTMLInputElement> | 14 | @ViewChild('avatarfileInput', { static: false }) avatarfileInput: ElementRef<HTMLInputElement> |
14 | 15 | ||
15 | @Input() actor: VideoChannel | Account | 16 | @Input() actor: VideoChannel | Account |
16 | 17 | ||
17 | @Output() avatarChange = new EventEmitter<FormData>() | 18 | @Output() avatarChange = new EventEmitter<FormData>() |
18 | 19 | ||
20 | private serverConfig: ServerConfig | ||
21 | |||
19 | constructor ( | 22 | constructor ( |
20 | private serverService: ServerService, | 23 | private serverService: ServerService, |
21 | private notifier: Notifier | 24 | private notifier: Notifier |
22 | ) {} | 25 | ) {} |
23 | 26 | ||
27 | ngOnInit (): void { | ||
28 | this.serverConfig = this.serverService.getTmpConfig() | ||
29 | this.serverService.getConfig() | ||
30 | .subscribe(config => this.serverConfig = config) | ||
31 | } | ||
32 | |||
24 | onAvatarChange () { | 33 | onAvatarChange () { |
25 | const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] | 34 | const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] |
26 | if (avatarfile.size > this.maxAvatarSize) { | 35 | if (avatarfile.size > this.maxAvatarSize) { |
@@ -35,10 +44,10 @@ export class ActorAvatarInfoComponent { | |||
35 | } | 44 | } |
36 | 45 | ||
37 | get maxAvatarSize () { | 46 | get maxAvatarSize () { |
38 | return this.serverService.getConfig().avatar.file.size.max | 47 | return this.serverConfig.avatar.file.size.max |
39 | } | 48 | } |
40 | 49 | ||
41 | get avatarExtensions () { | 50 | get avatarExtensions () { |
42 | return this.serverService.getConfig().avatar.file.extensions.join(',') | 51 | return this.serverConfig.avatar.file.extensions.join(',') |
43 | } | 52 | } |
44 | } | 53 | } |