]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-main/account/account.model.ts
Fix login form scrolling
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / account / account.model.ts
CommitLineData
80badf49 1import { Account as ServerAccount, ActorImage, BlockStatus } from '@shared/models'
67ed6552 2import { Actor } from './actor.model'
b1fa3eba 3
d3e91a5f 4export class Account extends Actor implements ServerAccount {
c5911fd3 5 displayName: string
2422c46b 6 description: string
dc2b2938
C
7
8 updatedAt: Date | string
9
ad9e39fb 10 nameWithHost: string
e379f813 11 nameWithHostForced: string
dc2b2938 12
65b21c96
C
13 mutedByUser: boolean
14 mutedByInstance: boolean
15 mutedServerByUser: boolean
16 mutedServerByInstance: boolean
6b738c7a 17
79bd2632
C
18 userId?: number
19
4428ad54 20 static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size?: number) {
d0800f76 21 return Actor.GET_ACTOR_AVATAR_URL(actor, size)
c418d483 22 }
23
4428ad54
C
24 static GET_DEFAULT_AVATAR_URL (size?: number) {
25 if (size && size <= 48) {
d0800f76 26 return `${window.location.origin}/client/assets/images/default-avatar-account-48x48.png`
27 }
28
c418d483 29 return `${window.location.origin}/client/assets/images/default-avatar-account.png`
30 }
31
6b738c7a 32 constructor (hash: ServerAccount) {
d3e91a5f
C
33 super(hash)
34
6b738c7a
C
35 this.displayName = hash.displayName
36 this.description = hash.description
79bd2632 37 this.userId = hash.userId
ad9e39fb 38 this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
e379f813 39 this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
af5767ff 40
dc2b2938
C
41 if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
42
65b21c96
C
43 this.mutedByUser = false
44 this.mutedByInstance = false
45 this.mutedServerByUser = false
46 this.mutedServerByInstance = false
6b738c7a 47 }
c418d483 48
d0800f76 49 updateAvatar (newAvatars: ActorImage[]) {
50 this.avatars = newAvatars
c418d483 51 }
52
1ea7da81 53 resetAvatar () {
d0800f76 54 this.avatars = []
c418d483 55 }
80badf49
C
56
57 updateBlockStatus (blockStatus: BlockStatus) {
58 this.mutedByInstance = blockStatus.accounts[this.nameWithHostForced].blockedByServer
59 this.mutedByUser = blockStatus.accounts[this.nameWithHostForced].blockedByUser
60 this.mutedServerByUser = blockStatus.hosts[this.host].blockedByUser
61 this.mutedServerByInstance = blockStatus.hosts[this.host].blockedByServer
62 }
b1fa3eba 63}