From 0e4ca570fa33105456f0e4650342374c1658d5f4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Jan 2021 10:52:17 +0100 Subject: Avatar info component optimizations --- .../account/actor-avatar-info.component.html | 6 ++-- .../account/actor-avatar-info.component.ts | 37 ++++++++-------------- 2 files changed, 17 insertions(+), 26 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/account/actor-avatar-info.component.html b/client/src/app/shared/shared-main/account/actor-avatar-info.component.html index a34d27b26..30584fd00 100644 --- a/client/src/app/shared/shared-main/account/actor-avatar-info.component.html +++ b/client/src/app/shared/shared-main/account/actor-avatar-info.component.html @@ -5,13 +5,13 @@
-
+
-
+
@@ -40,4 +40,4 @@ Remove avatar
- \ No newline at end of file + 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 @@ import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' import { Notifier, ServerService } from '@app/core' +import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' import { getBytes } from '@root-helpers/bytes' -import { ServerConfig } from '@shared/models' -import { VideoChannel } from '../video-channel/video-channel.model' import { Account } from '../account/account.model' -import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' +import { VideoChannel } from '../video-channel/video-channel.model' import { Actor } from './actor.model' @Component({ @@ -21,8 +20,11 @@ export class ActorAvatarInfoComponent implements OnInit, OnChanges { @Output() avatarChange = new EventEmitter() @Output() avatarDelete = new EventEmitter() + avatarFormat = '' + maxAvatarSize = 0 + avatarExtensions = '' + private avatarUrl: string - private serverConfig: ServerConfig constructor ( private serverService: ServerService, @@ -30,9 +32,14 @@ export class ActorAvatarInfoComponent implements OnInit, OnChanges { ) { } ngOnInit (): void { - this.serverConfig = this.serverService.getTmpConfig() this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + .subscribe(config => { + this.maxAvatarSize = config.avatar.file.size.max + this.avatarExtensions = config.avatar.file.extensions.join(', ') + + this.avatarFormat = `${$localize`max size`}: 192*192px, ` + + `${getBytes(this.maxAvatarSize)} ${$localize`extensions`}: ${this.avatarExtensions}` + }) } ngOnChanges (changes: SimpleChanges) { @@ -60,23 +67,7 @@ export class ActorAvatarInfoComponent implements OnInit, OnChanges { this.avatarDelete.emit() } - get maxAvatarSize () { - return this.serverConfig.avatar.file.size.max - } - - get maxAvatarSizeInBytes () { - return getBytes(this.maxAvatarSize) - } - - get avatarExtensions () { - return this.serverConfig.avatar.file.extensions.join(', ') - } - - get avatarFormat () { - return `${$localize`max size`}: 192*192px, ${this.maxAvatarSizeInBytes} ${$localize`extensions`}: ${this.avatarExtensions}` - } - - get hasAvatar () { + hasAvatar () { return !!this.avatarUrl } } -- cgit v1.2.3