diff options
author | kimsible <kimsible@users.noreply.github.com> | 2020-11-18 19:20:05 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 11:12:06 +0100 |
commit | c418d483004dfbae9ea38d54aa1577db46d34a8a (patch) | |
tree | c4fd4ec790c6e5d6bc44e887090a8286e10fffd2 /client/src/app/shared/shared-main/account/account.model.ts | |
parent | 18490b07650d77d7fe376970b749af5a8c672fd6 (diff) | |
download | PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.tar.gz PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.tar.zst PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.zip |
Add new default different avatar for channel and account
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.ts | 22 |
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 @@ | |||
1 | import { Account as ServerAccount } from '@shared/models/actors/account.model' | 1 | import { Account as ServerAccount, Avatar } from '@shared/models' |
2 | import { Actor } from './actor.model' | 2 | import { Actor } from './actor.model' |
3 | 3 | ||
4 | export class Account extends Actor implements ServerAccount { | 4 | export 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 | } |