aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/users
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/users')
-rw-r--r--client/src/app/shared/users/user.model.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts
index 2bdc48a1d..d4551de89 100644
--- a/client/src/app/shared/users/user.model.ts
+++ b/client/src/app/shared/users/user.model.ts
@@ -1,6 +1,6 @@
1import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' 1import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
2import { Account } from '../account/account.model'
3import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' 2import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
3import { Actor } from '@app/shared/actor/actor.model'
4 4
5export type UserConstructorHash = { 5export type UserConstructorHash = {
6 id: number, 6 id: number,
@@ -25,6 +25,7 @@ export class User implements UserServerModel {
25 account: Account 25 account: Account
26 videoChannels: VideoChannel[] 26 videoChannels: VideoChannel[]
27 createdAt: Date 27 createdAt: Date
28 accountAvatarUrl: string
28 29
29 constructor (hash: UserConstructorHash) { 30 constructor (hash: UserConstructorHash) {
30 this.id = hash.id 31 this.id = hash.id
@@ -52,19 +53,23 @@ export class User implements UserServerModel {
52 if (hash.createdAt !== undefined) { 53 if (hash.createdAt !== undefined) {
53 this.createdAt = hash.createdAt 54 this.createdAt = hash.createdAt
54 } 55 }
56
57 this.updateComputedAttributes()
55 } 58 }
56 59
57 hasRight (right: UserRight) { 60 hasRight (right: UserRight) {
58 return hasUserRight(this.role, right) 61 return hasUserRight(this.role, right)
59 } 62 }
60 63
61 getAvatarUrl () {
62 return Account.GET_ACCOUNT_AVATAR_URL(this.account)
63 }
64
65 patch (obj: UserServerModel) { 64 patch (obj: UserServerModel) {
66 for (const key of Object.keys(obj)) { 65 for (const key of Object.keys(obj)) {
67 this[key] = obj[key] 66 this[key] = obj[key]
68 } 67 }
68
69 this.updateComputedAttributes()
70 }
71
72 private updateComputedAttributes () {
73 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
69 } 74 }
70} 75}