import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier, ServerService } from '@app/core'
import { Account, VideoChannel } from '@app/shared/shared-main'
-import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { getBytes } from '@root-helpers/bytes'
import { imageToDataURL } from '@root-helpers/images'
})
export class ActorAvatarEditComponent implements OnInit {
@ViewChild('avatarfileInput') avatarfileInput: ElementRef<HTMLInputElement>
- @ViewChild('avatarPopover') avatarPopover: NgbPopover
@Input() actor: VideoChannel | Account
@Input() editable = true
const formData = new FormData()
formData.append('avatarfile', avatarfile)
- this.avatarPopover?.close()
this.avatarChange.emit(formData)
if (this.previewImage) {
}
hasAvatar () {
- return !!this.preview || !!this.actor.avatar
+ return !!this.preview || this.actor.avatars.length !== 0
}
- isChannel () {
- return !!(this.actor as VideoChannel).ownerAccount
- }
-
- getChannel (): VideoChannel {
- if (this.isChannel()) return this.actor as VideoChannel
-
- return undefined
- }
-
- getAccount (): Account {
- if (this.isChannel()) return undefined
+ getActorType () {
+ if ((this.actor as VideoChannel).ownerAccount) return 'channel'
- return this.actor as Account
+ return 'account'
}
}