From d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Apr 2018 15:43:19 +0200 Subject: Add video channel account list --- client/src/app/shared/users/user.model.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'client/src/app/shared/users/user.model.ts') 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 @@ -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) } } -- cgit v1.2.3