]>
Commit | Line | Data |
---|---|---|
c6c0fa6c C |
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', | |
12 | name: 'thumbnailfile' | |
13 | }, | |
14 | { | |
15 | url: '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({ | |
9df52d66 | 27 | [obj.name]: data |
c6c0fa6c C |
28 | }) |
29 | }) | |
30 | } | |
31 | } | |
32 | ||
33 | export { | |
34 | hydrateFormFromVideo | |
35 | } |