]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-main/account/account.model.ts
Remove avatarUrl from models
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / account / account.model.ts
1 import { Account as ServerAccount, Actor as ServerActor, ActorImage } from '@shared/models'
2 import { Actor } from './actor.model'
3
4 export class Account extends Actor implements ServerAccount {
5 displayName: string
6 description: string
7 nameWithHost: string
8 nameWithHostForced: string
9 mutedByUser: boolean
10 mutedByInstance: boolean
11 mutedServerByUser: boolean
12 mutedServerByInstance: boolean
13
14 userId?: number
15
16 static GET_ACTOR_AVATAR_URL (actor: { avatar?: { url?: string, path: string } }) {
17 return Actor.GET_ACTOR_AVATAR_URL(actor)
18 }
19
20 static GET_DEFAULT_AVATAR_URL () {
21 return `${window.location.origin}/client/assets/images/default-avatar-account.png`
22 }
23
24 constructor (hash: ServerAccount) {
25 super(hash)
26
27 this.displayName = hash.displayName
28 this.description = hash.description
29 this.userId = hash.userId
30 this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
31 this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
32
33 this.mutedByUser = false
34 this.mutedByInstance = false
35 this.mutedServerByUser = false
36 this.mutedServerByInstance = false
37 }
38
39 updateAvatar (newAvatar: ActorImage) {
40 this.avatar = newAvatar
41 }
42
43 resetAvatar () {
44 this.avatar = null
45 }
46 }