1 import { Account as ServerAccount, Avatar } from '@shared/models'
2 import { Actor } from './actor.model'
4 export class Account extends Actor implements ServerAccount {
8 nameWithHostForced: string
10 mutedByInstance: boolean
11 mutedServerByUser: boolean
12 mutedServerByInstance: boolean
16 static GET_ACTOR_AVATAR_URL (actor: object) {
17 return Actor.GET_ACTOR_AVATAR_URL(actor) || this.GET_DEFAULT_AVATAR_URL()
20 static GET_DEFAULT_AVATAR_URL () {
21 return `${window.location.origin}/client/assets/images/default-avatar-account.png`
24 constructor (hash: ServerAccount) {
27 this.updateComputedAttributes()
29 this.displayName = hash.displayName
30 this.description = hash.description
31 this.userId = hash.userId
32 this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
33 this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
35 this.mutedByUser = false
36 this.mutedByInstance = false
37 this.mutedServerByUser = false
38 this.mutedServerByInstance = false
41 updateAvatar (newAvatar: Avatar) {
42 this.avatar = newAvatar
44 this.updateComputedAttributes()
49 this.avatarUrl = Account.GET_DEFAULT_AVATAR_URL()
52 private updateComputedAttributes () {
53 this.avatarUrl = Account.GET_ACTOR_AVATAR_URL(this)