]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/users/user.model.ts
Add video channel account list
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
index 2bdc48a1dc81a381ba0cda7915e7f0069aca296d..d4551de894b699fa7f358cbeda1bdae01fb17888 100644 (file)
@@ -1,6 +1,6 @@
-import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
-import { Account } from '../account/account.model'
+import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
 import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
+import { Actor } from '@app/shared/actor/actor.model'
 
 export type UserConstructorHash = {
   id: number,
@@ -25,6 +25,7 @@ export class User implements UserServerModel {
   account: Account
   videoChannels: VideoChannel[]
   createdAt: Date
+  accountAvatarUrl: string
 
   constructor (hash: UserConstructorHash) {
     this.id = hash.id
@@ -52,19 +53,23 @@ export class User implements UserServerModel {
     if (hash.createdAt !== undefined) {
       this.createdAt = hash.createdAt
     }
+
+    this.updateComputedAttributes()
   }
 
   hasRight (right: UserRight) {
     return hasUserRight(this.role, right)
   }
 
-  getAvatarUrl () {
-    return Account.GET_ACCOUNT_AVATAR_URL(this.account)
-  }
-
   patch (obj: UserServerModel) {
     for (const key of Object.keys(obj)) {
       this[key] = obj[key]
     }
+
+    this.updateComputedAttributes()
+  }
+
+  private updateComputedAttributes () {
+    this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
   }
 }