]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+videos/+video-edit/shared/video-edit-utils.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / shared / video-edit-utils.ts
1 import { FormGroup } from '@angular/forms'
2 import { VideoEdit } from '@app/shared/shared-main'
3
4 function hydrateFormFromVideo (formGroup: FormGroup, video: VideoEdit, thumbnailFiles: boolean) {
5 formGroup.patchValue(video.toFormPatch())
6
7 if (thumbnailFiles === false) return
8
9 const objects = [
10 {
11 url: 'thumbnailUrl' as 'thumbnailUrl',
12 name: 'thumbnailfile'
13 },
14 {
15 url: 'previewUrl' as 'previewUrl',
16 name: 'previewfile'
17 }
18 ]
19
20 for (const obj of objects) {
21 if (!video[obj.url]) continue
22
23 fetch(video[obj.url])
24 .then(response => response.blob())
25 .then(data => {
26 formGroup.patchValue({
27 [obj.name]: data
28 })
29 })
30 }
31 }
32
33 export {
34 hydrateFormFromVideo
35 }