From 2de96f4d6b800076743ed2073f9529816cfd5c8a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Oct 2017 20:26:06 +0100 Subject: Lazy description and previews to video form --- .../app/videos/+video-edit/video-add.component.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'client/src/app/videos/+video-edit/video-add.component.ts') 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 92b03e8c9..5b5557ed9 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -82,7 +82,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { category: [ '', VIDEO_CATEGORY.VALIDATORS ], licence: [ '', VIDEO_LICENCE.VALIDATORS ], language: [ '', VIDEO_LANGUAGE.VALIDATORS ], - channelId: [ this.userVideoChannels[0].id, VIDEO_CHANNEL.VALIDATORS ], + channelId: [ '', VIDEO_CHANNEL.VALIDATORS ], description: [ '', VIDEO_DESCRIPTION.VALIDATORS ], videofile: [ '', VIDEO_FILE.VALIDATORS ], tags: [ '' ] @@ -96,10 +96,22 @@ export class VideoAddComponent extends FormReactive implements OnInit { this.videoLicences = this.serverService.getVideoLicences() this.videoLanguages = this.serverService.getVideoLanguages() - const user = this.authService.getUser() - this.userVideoChannels = user.videoChannels.map(v => ({ id: v.id, label: v.name })) - this.buildForm() + + this.authService.userInformationLoaded + .subscribe( + () => { + const user = this.authService.getUser() + if (!user) return + + const videoChannels = user.videoChannels + if (Array.isArray(videoChannels) === false) return + + this.userVideoChannels = videoChannels.map(v => ({ id: v.id, label: v.name })) + + this.form.patchValue({ channelId: this.userVideoChannels[0].id }) + } + ) } // The goal is to keep reactive form validation (required field) -- cgit v1.2.3