X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fusers%2Fuser.model.ts;h=2bdc48a1dc81a381ba0cda7915e7f0069aca296d;hb=03e12d7c4954e1071fdeb7ef362ea5c3965d4075;hp=b1c323114bf8b55fdc48f449ccb6f0a71f3466fb;hpb=d235f6b0d1054a2a3451dacade927caefce8f30c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index b1c323114..2bdc48a1d 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -1,5 +1,6 @@ import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' -import { Account } from '../../../../../shared/models/accounts' +import { Account } from '../account/account.model' +import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' export type UserConstructorHash = { id: number, @@ -7,7 +8,8 @@ export type UserConstructorHash = { email: string, role: UserRole, videoQuota?: number, - displayNSFW?: boolean, + nsfwPolicy?: NSFWPolicyType, + autoPlayVideo?: boolean, createdAt?: Date, account?: Account, videoChannels?: VideoChannel[] @@ -17,7 +19,8 @@ export class User implements UserServerModel { username: string email: string role: UserRole - displayNSFW: boolean + nsfwPolicy: NSFWPolicyType + autoPlayVideo: boolean videoQuota: number account: Account videoChannels: VideoChannel[] @@ -38,8 +41,12 @@ export class User implements UserServerModel { this.videoQuota = hash.videoQuota } - if (hash.displayNSFW !== undefined) { - this.displayNSFW = hash.displayNSFW + if (hash.nsfwPolicy !== undefined) { + this.nsfwPolicy = hash.nsfwPolicy + } + + if (hash.autoPlayVideo !== undefined) { + this.autoPlayVideo = hash.autoPlayVideo } if (hash.createdAt !== undefined) { @@ -51,9 +58,13 @@ export class User implements UserServerModel { return hasUserRight(this.role, right) } - getAvatarPath () { - if (this.account && this.account.avatar) return this.account.avatar.path + getAvatarUrl () { + return Account.GET_ACCOUNT_AVATAR_URL(this.account) + } - return API_URL + '/client/assets/images/default-avatar.png' + patch (obj: UserServerModel) { + for (const key of Object.keys(obj)) { + this[key] = obj[key] + } } }