aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/actor/actor.model.ts10
-rw-r--r--client/src/app/shared/users/user.model.ts17
-rw-r--r--client/src/app/shared/video-channel/video-channel.service.ts8
-rw-r--r--client/src/app/shared/video/video.model.ts3
4 files changed, 27 insertions, 11 deletions
diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts
index f820dc3c4..811afb449 100644
--- a/client/src/app/shared/actor/actor.model.ts
+++ b/client/src/app/shared/actor/actor.model.ts
@@ -45,6 +45,16 @@ export abstract class Actor implements ActorServer {
45 this.updatedAt = new Date(hash.updatedAt.toString()) 45 this.updatedAt = new Date(hash.updatedAt.toString())
46 this.avatar = hash.avatar 46 this.avatar = hash.avatar
47 47
48 this.updateComputedAttributes()
49 }
50
51 updateAvatar (newAvatar: Avatar) {
52 this.avatar = newAvatar
53
54 this.updateComputedAttributes()
55 }
56
57 private updateComputedAttributes () {
48 this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this) 58 this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
49 } 59 }
50} 60}
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts
index 60a0f26df..581ea7859 100644
--- a/client/src/app/shared/users/user.model.ts
+++ b/client/src/app/shared/users/user.model.ts
@@ -34,7 +34,6 @@ export class User implements UserServerModel {
34 account: Account 34 account: Account
35 videoChannels: VideoChannel[] 35 videoChannels: VideoChannel[]
36 createdAt: Date 36 createdAt: Date
37 accountAvatarUrl: string
38 37
39 constructor (hash: UserConstructorHash) { 38 constructor (hash: UserConstructorHash) {
40 this.id = hash.id 39 this.id = hash.id
@@ -65,8 +64,12 @@ export class User implements UserServerModel {
65 if (hash.createdAt !== undefined) { 64 if (hash.createdAt !== undefined) {
66 this.createdAt = hash.createdAt 65 this.createdAt = hash.createdAt
67 } 66 }
67 }
68
69 get accountAvatarUrl () {
70 if (!this.account) return ''
68 71
69 this.updateComputedAttributes() 72 return this.account.avatarUrl
70 } 73 }
71 74
72 hasRight (right: UserRight) { 75 hasRight (right: UserRight) {
@@ -81,17 +84,9 @@ export class User implements UserServerModel {
81 if (obj.account !== undefined) { 84 if (obj.account !== undefined) {
82 this.account = new Account(obj.account) 85 this.account = new Account(obj.account)
83 } 86 }
84
85 this.updateComputedAttributes()
86 } 87 }
87 88
88 updateAccountAvatar (newAccountAvatar: Avatar) { 89 updateAccountAvatar (newAccountAvatar: Avatar) {
89 this.account.avatar = newAccountAvatar 90 this.account.updateAvatar(newAccountAvatar)
90
91 this.updateComputedAttributes()
92 }
93
94 private updateComputedAttributes () {
95 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
96 } 91 }
97} 92}
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts
index 55e4c2a31..0b9900208 100644
--- a/client/src/app/shared/video-channel/video-channel.service.ts
+++ b/client/src/app/shared/video-channel/video-channel.service.ts
@@ -9,6 +9,7 @@ import { ResultList } from '../../../../../shared'
9import { VideoChannel } from './video-channel.model' 9import { VideoChannel } from './video-channel.model'
10import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
11import { Account } from '@app/shared/account/account.model' 11import { Account } from '@app/shared/account/account.model'
12import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
12 13
13@Injectable() 14@Injectable()
14export class VideoChannelService { 15export class VideoChannelService {
@@ -54,6 +55,13 @@ export class VideoChannelService {
54 ) 55 )
55 } 56 }
56 57
58 changeVideoChannelAvatar (videoChannelUUID: string, avatarForm: FormData) {
59 const url = VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID + '/avatar/pick'
60
61 return this.authHttp.post<{ avatar: Avatar }>(url, avatarForm)
62 .pipe(catchError(this.restExtractor.handleError))
63 }
64
57 removeVideoChannel (videoChannel: VideoChannel) { 65 removeVideoChannel (videoChannel: VideoChannel) {
58 return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid) 66 return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid)
59 .pipe( 67 .pipe(
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 7f421dbbb..5c820a227 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -11,6 +11,7 @@ import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-s
11export class Video implements VideoServerModel { 11export class Video implements VideoServerModel {
12 by: string 12 by: string
13 accountAvatarUrl: string 13 accountAvatarUrl: string
14 videoChannelAvatarUrl: string
14 createdAt: Date 15 createdAt: Date
15 updatedAt: Date 16 updatedAt: Date
16 publishedAt: Date 17 publishedAt: Date
@@ -102,9 +103,11 @@ export class Video implements VideoServerModel {
102 this.dislikes = hash.dislikes 103 this.dislikes = hash.dislikes
103 this.nsfw = hash.nsfw 104 this.nsfw = hash.nsfw
104 this.account = hash.account 105 this.account = hash.account
106 this.channel = hash.channel
105 107
106 this.by = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host) 108 this.by = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
107 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) 109 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
110 this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.channel)
108 111
109 this.category.label = peertubeTranslate(this.category.label, translations) 112 this.category.label = peertubeTranslate(this.category.label, translations)
110 this.licence.label = peertubeTranslate(this.licence.label, translations) 113 this.licence.label = peertubeTranslate(this.licence.label, translations)