From 6200d8d91710b03a72a27e35cbe6eed1e6cc8c62 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 16 May 2018 11:33:11 +0200 Subject: Fix video channel update with an admin account --- .../app/videos/+video-edit/video-add.component.ts | 1 - .../app/videos/+video-edit/video-update.component.ts | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'client/src') diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 41d14573c..032504cea 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -219,7 +219,6 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy const video = new VideoEdit() video.patch(this.form.value) - video.channelId = this.firstStepChannelId video.id = this.videoUploadedIds.id video.uuid = this.videoUploadedIds.uuid diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index b1d80bcaa..00c2ed3f1 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -11,7 +11,7 @@ import { FormReactive } from '../../shared' import { ValidatorMessage } from '../../shared/forms/form-validators/validator-message' import { VideoEdit } from '../../shared/video/video-edit.model' import { VideoService } from '../../shared/video/video.service' -import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils' +import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' @Component({ selector: 'my-videos-update', @@ -36,7 +36,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { private serverService: ServerService, private videoService: VideoService, private authService: AuthService, - private loadingBar: LoadingBarService + private loadingBar: LoadingBarService, + private videoChannelService: VideoChannelService ) { super() } @@ -59,14 +60,21 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { return this.videoService .loadCompleteDescription(video.descriptionPath) .pipe(map(description => Object.assign(video, { description }))) + }), + switchMap(video => { + return this.videoChannelService + .listAccountVideoChannels(video.account.id) + .pipe( + map(result => result.data), + map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName }))), + map(videoChannels => ({ video, videoChannels })) + ) }) ) .subscribe( - video => { + ({ video, videoChannels }) => { this.video = new VideoEdit(video) - - populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) - .catch(err => console.error(err)) + this.userVideoChannels = videoChannels // We cannot set private a video that was not private if (video.privacy.id !== VideoPrivacy.PRIVATE) { -- cgit v1.2.3