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({
@Output() avatarChange = new EventEmitter<FormData>()
@Output() avatarDelete = new EventEmitter<void>()
+ avatarFormat = ''
+ maxAvatarSize = 0
+ avatarExtensions = ''
+
private avatarUrl: string
- private serverConfig: ServerConfig
constructor (
private serverService: ServerService,
) { }
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) {
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}`
+ hasAvatar () {
+ return !!this.avatarUrl
}
- get hasAvatar () {
- return !!this.avatarUrl
+ isChannel () {
+ return !!(this.actor as VideoChannel).ownerAccount
}
}