aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/account/account.model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/account/account.model.ts')
-rw-r--r--client/src/app/shared/shared-main/account/account.model.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-main/account/account.model.ts b/client/src/app/shared/shared-main/account/account.model.ts
index 6df2e9d10..b3dc6cfe5 100644
--- a/client/src/app/shared/shared-main/account/account.model.ts
+++ b/client/src/app/shared/shared-main/account/account.model.ts
@@ -1,4 +1,4 @@
1import { Account as ServerAccount } from '@shared/models/actors/account.model' 1import { Account as ServerAccount, Avatar } from '@shared/models'
2import { Actor } from './actor.model' 2import { Actor } from './actor.model'
3 3
4export class Account extends Actor implements ServerAccount { 4export class Account extends Actor implements ServerAccount {
@@ -13,9 +13,19 @@ export class Account extends Actor implements ServerAccount {
13 13
14 userId?: number 14 userId?: number
15 15
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
16 constructor (hash: ServerAccount) { 24 constructor (hash: ServerAccount) {
17 super(hash) 25 super(hash)
18 26
27 this.updateComputedAttributes()
28
19 this.displayName = hash.displayName 29 this.displayName = hash.displayName
20 this.description = hash.description 30 this.description = hash.description
21 this.userId = hash.userId 31 this.userId = hash.userId
@@ -27,4 +37,14 @@ export class Account extends Actor implements ServerAccount {
27 this.mutedServerByUser = false 37 this.mutedServerByUser = false
28 this.mutedServerByInstance = false 38 this.mutedServerByInstance = false
29 } 39 }
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 }
30} 50}