]>
Commit | Line | Data |
---|---|---|
c418d483 | 1 | import { Account as ServerAccount, Avatar } from '@shared/models' |
67ed6552 | 2 | import { Actor } from './actor.model' |
b1fa3eba | 3 | |
d3e91a5f | 4 | export class Account extends Actor implements ServerAccount { |
c5911fd3 | 5 | displayName: string |
2422c46b | 6 | description: string |
ad9e39fb | 7 | nameWithHost: string |
e379f813 | 8 | nameWithHostForced: string |
65b21c96 C |
9 | mutedByUser: boolean |
10 | mutedByInstance: boolean | |
11 | mutedServerByUser: boolean | |
12 | mutedServerByInstance: boolean | |
6b738c7a | 13 | |
79bd2632 C |
14 | userId?: number |
15 | ||
c418d483 | 16 | static GET_ACTOR_AVATAR_URL (actor: object) { |
17 | return Actor.GET_ACTOR_AVATAR_URL(actor) || this.GET_DEFAULT_AVATAR_URL() | |
18 | } | |
19 | ||
20 | static GET_DEFAULT_AVATAR_URL () { | |
21 | return `${window.location.origin}/client/assets/images/default-avatar-account.png` | |
22 | } | |
23 | ||
6b738c7a | 24 | constructor (hash: ServerAccount) { |
d3e91a5f C |
25 | super(hash) |
26 | ||
c418d483 | 27 | this.updateComputedAttributes() |
28 | ||
6b738c7a C |
29 | this.displayName = hash.displayName |
30 | this.description = hash.description | |
79bd2632 | 31 | this.userId = hash.userId |
ad9e39fb | 32 | this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) |
e379f813 | 33 | this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true) |
af5767ff | 34 | |
65b21c96 C |
35 | this.mutedByUser = false |
36 | this.mutedByInstance = false | |
37 | this.mutedServerByUser = false | |
38 | this.mutedServerByInstance = false | |
6b738c7a | 39 | } |
c418d483 | 40 | |
41 | updateAvatar (newAvatar: Avatar) { | |
42 | this.avatar = newAvatar | |
43 | ||
44 | this.updateComputedAttributes() | |
45 | } | |
46 | ||
47 | private updateComputedAttributes () { | |
48 | this.avatarUrl = Account.GET_ACTOR_AVATAR_URL(this) | |
49 | } | |
b1fa3eba | 50 | } |