import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
import { Actor } from '@app/shared/actor/actor.model'
import { Account } from '@app/shared/account/account.model'
+import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
export type UserConstructorHash = {
id: number,
account: Account
videoChannels: VideoChannel[]
createdAt: Date
- accountAvatarUrl: string
constructor (hash: UserConstructorHash) {
this.id = hash.id
if (hash.createdAt !== undefined) {
this.createdAt = hash.createdAt
}
+ }
+
+ get accountAvatarUrl () {
+ if (!this.account) return ''
- this.updateComputedAttributes()
+ return this.account.avatarUrl
}
hasRight (right: UserRight) {
if (obj.account !== undefined) {
this.account = new Account(obj.account)
}
-
- this.updateComputedAttributes()
}
- private updateComputedAttributes () {
- this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
+ updateAccountAvatar (newAccountAvatar: Avatar) {
+ this.account.updateAvatar(newAccountAvatar)
}
}