aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-04 11:31:22 +0200
committerChocobozzz <me@florianbigard.com>2022-07-04 11:31:22 +0200
commit0146f3516ec458d7eaba3ede2addb23005bd4a28 (patch)
tree6a7742feb5087af2d62c0478751678e93837a56f /client/src/app/+videos
parentcd25344f741e8c97b113b36eb6babc7be490114d (diff)
downloadPeerTube-0146f3516ec458d7eaba3ede2addb23005bd4a28.tar.gz
PeerTube-0146f3516ec458d7eaba3ede2addb23005bd4a28.tar.zst
PeerTube-0146f3516ec458d7eaba3ede2addb23005bd4a28.zip
Fix comments/download attributes on import
Diffstat (limited to 'client/src/app/+videos')
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts16
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts34
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.html2
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.ts22
4 files changed, 27 insertions, 47 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
index c369ba2b7..da4996902 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
@@ -1,3 +1,4 @@
1import { switchMap } from 'rxjs'
1import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' 2import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
2import { Router } from '@angular/router' 3import { Router } from '@angular/router'
3import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 4import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
@@ -87,21 +88,16 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
87 this.loadingBar.useRef().start() 88 this.loadingBar.useRef().start()
88 89
89 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate) 90 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)
91 .pipe(switchMap(({ video }) => this.videoService.getVideo({ videoId: video.uuid })))
90 .subscribe({ 92 .subscribe({
91 next: res => { 93 next: video => {
92 this.loadingBar.useRef().complete() 94 this.loadingBar.useRef().complete()
93 this.firstStepDone.emit(res.video.name) 95 this.firstStepDone.emit(video.name)
94 this.isImportingVideo = false 96 this.isImportingVideo = false
95 this.hasImportedVideo = true 97 this.hasImportedVideo = true
96 98
97 this.video = new VideoEdit(Object.assign(res.video, { 99 this.video = new VideoEdit(video)
98 commentsEnabled: videoUpdate.commentsEnabled, 100 this.video.patch({ privacy: this.firstStepPrivacyId })
99 downloadEnabled: videoUpdate.downloadEnabled,
100 privacy: { id: this.firstStepPrivacyId },
101 support: null,
102 thumbnailUrl: null,
103 previewUrl: null
104 }))
105 101
106 hydrateFormFromVideo(this.form, this.video, false) 102 hydrateFormFromVideo(this.form, this.video, false)
107 }, 103 },
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
index 4c74eda84..971a2a070 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
@@ -1,8 +1,9 @@
1import { forkJoin } from 'rxjs'
1import { map, switchMap } from 'rxjs/operators' 2import { map, switchMap } from 'rxjs/operators'
2import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular/core' 3import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular/core'
3import { Router } from '@angular/router' 4import { Router } from '@angular/router'
4import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 5import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
5import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers' 6import { scrollToTop } from '@app/helpers'
6import { FormValidatorService } from '@app/shared/shared-forms' 7import { FormValidatorService } from '@app/shared/shared-forms'
7import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' 8import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
8import { LoadingBarService } from '@ngx-loading-bar/core' 9import { LoadingBarService } from '@ngx-loading-bar/core'
@@ -76,12 +77,11 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
76 this.videoImportService 77 this.videoImportService
77 .importVideoUrl(this.targetUrl, videoUpdate) 78 .importVideoUrl(this.targetUrl, videoUpdate)
78 .pipe( 79 .pipe(
79 switchMap(res => { 80 switchMap(previous => {
80 return this.videoCaptionService 81 return forkJoin([
81 .listCaptions(res.video.uuid) 82 this.videoCaptionService.listCaptions(previous.video.uuid),
82 .pipe( 83 this.videoService.getVideo({ videoId: previous.video.uuid })
83 map(result => ({ video: res.video, videoCaptions: result.data })) 84 ]).pipe(map(([ videoCaptionsResult, video ]) => ({ videoCaptions: videoCaptionsResult.data, video })))
84 )
85 }) 85 })
86 ) 86 )
87 .subscribe({ 87 .subscribe({
@@ -91,24 +91,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
91 this.isImportingVideo = false 91 this.isImportingVideo = false
92 this.hasImportedVideo = true 92 this.hasImportedVideo = true
93 93
94 const absoluteAPIUrl = getAbsoluteAPIUrl() 94 this.video = new VideoEdit(video)
95 95 this.video.patch({ privacy: this.firstStepPrivacyId })
96 const thumbnailUrl = video.thumbnailPath
97 ? absoluteAPIUrl + video.thumbnailPath
98 : null
99
100 const previewUrl = video.previewPath
101 ? absoluteAPIUrl + video.previewPath
102 : null
103
104 this.video = new VideoEdit(Object.assign(video, {
105 commentsEnabled: videoUpdate.commentsEnabled,
106 downloadEnabled: videoUpdate.downloadEnabled,
107 privacy: { id: this.firstStepPrivacyId },
108 support: null,
109 thumbnailUrl,
110 previewUrl
111 }))
112 96
113 this.videoCaptions = videoCaptions 97 this.videoCaptions = videoCaptions
114 98
diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html
index ffd125695..a33ac3db4 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.html
+++ b/client/src/app/+videos/+video-edit/video-update.component.html
@@ -1,7 +1,7 @@
1<div class="margin-content"> 1<div class="margin-content">
2 <div class="title-page"> 2 <div class="title-page">
3 <span class="me-1" i18n>Update</span> 3 <span class="me-1" i18n>Update</span>
4 <a [routerLink]="getVideoUrl()">{{ video?.name }}</a> 4 <a [routerLink]="getVideoUrl()">{{ videoDetails?.name }}</a>
5 </div> 5 </div>
6 6
7 <form novalidate [formGroup]="form"> 7 <form novalidate [formGroup]="form">
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 43e8ba3e5..13e786a8e 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -18,7 +18,7 @@ import { VideoSource } from '@shared/models/videos/video-source'
18 templateUrl: './video-update.component.html' 18 templateUrl: './video-update.component.html'
19}) 19})
20export class VideoUpdateComponent extends FormReactive implements OnInit { 20export class VideoUpdateComponent extends FormReactive implements OnInit {
21 video: VideoEdit 21 videoEdit: VideoEdit
22 videoDetails: VideoDetails 22 videoDetails: VideoDetails
23 videoSource: VideoSource 23 videoSource: VideoSource
24 userVideoChannels: SelectChannelItem[] = [] 24 userVideoChannels: SelectChannelItem[] = []
@@ -50,19 +50,19 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
50 const { videoData } = this.route.snapshot.data 50 const { videoData } = this.route.snapshot.data
51 const { video, videoChannels, videoCaptions, videoSource, liveVideo } = videoData 51 const { video, videoChannels, videoCaptions, videoSource, liveVideo } = videoData
52 52
53 this.video = new VideoEdit(video)
54 this.videoDetails = video 53 this.videoDetails = video
54 this.videoEdit = new VideoEdit(this.videoDetails)
55 55
56 this.userVideoChannels = videoChannels 56 this.userVideoChannels = videoChannels
57 this.videoCaptions = videoCaptions 57 this.videoCaptions = videoCaptions
58 this.videoSource = videoSource 58 this.videoSource = videoSource
59 this.liveVideo = liveVideo 59 this.liveVideo = liveVideo
60 60
61 this.forbidScheduledPublication = this.video.privacy !== VideoPrivacy.PRIVATE 61 this.forbidScheduledPublication = this.videoEdit.privacy !== VideoPrivacy.PRIVATE
62 } 62 }
63 63
64 onFormBuilt () { 64 onFormBuilt () {
65 hydrateFormFromVideo(this.form, this.video, true) 65 hydrateFormFromVideo(this.form, this.videoEdit, true)
66 66
67 if (this.liveVideo) { 67 if (this.liveVideo) {
68 this.form.patchValue({ 68 this.form.patchValue({
@@ -115,16 +115,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
115 return 115 return
116 } 116 }
117 117
118 this.video.patch(this.form.value) 118 this.videoEdit.patch(this.form.value)
119 119
120 this.loadingBar.useRef().start() 120 this.loadingBar.useRef().start()
121 this.isUpdatingVideo = true 121 this.isUpdatingVideo = true
122 122
123 // Update the video 123 // Update the video
124 this.videoService.updateVideo(this.video) 124 this.videoService.updateVideo(this.videoEdit)
125 .pipe( 125 .pipe(
126 // Then update captions 126 // Then update captions
127 switchMap(() => this.videoCaptionService.updateCaptions(this.video.id, this.videoCaptions)), 127 switchMap(() => this.videoCaptionService.updateCaptions(this.videoEdit.id, this.videoCaptions)),
128 128
129 switchMap(() => { 129 switchMap(() => {
130 if (!this.liveVideo) return of(undefined) 130 if (!this.liveVideo) return of(undefined)
@@ -140,7 +140,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
140 .some(key => this.liveVideo[key] !== liveVideoUpdate[key]) 140 .some(key => this.liveVideo[key] !== liveVideoUpdate[key])
141 if (!liveChanged) return of(undefined) 141 if (!liveChanged) return of(undefined)
142 142
143 return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) 143 return this.liveVideoService.updateLive(this.videoEdit.id, liveVideoUpdate)
144 }) 144 })
145 ) 145 )
146 .subscribe({ 146 .subscribe({
@@ -149,7 +149,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
149 this.isUpdatingVideo = false 149 this.isUpdatingVideo = false
150 this.loadingBar.useRef().complete() 150 this.loadingBar.useRef().complete()
151 this.notifier.success($localize`Video updated.`) 151 this.notifier.success($localize`Video updated.`)
152 this.router.navigateByUrl(Video.buildWatchUrl(this.video)) 152 this.router.navigateByUrl(Video.buildWatchUrl(this.videoEdit))
153 }, 153 },
154 154
155 error: err => { 155 error: err => {
@@ -162,10 +162,10 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
162 } 162 }
163 163
164 hydratePluginFieldsFromVideo () { 164 hydratePluginFieldsFromVideo () {
165 if (!this.video.pluginData) return 165 if (!this.videoEdit.pluginData) return
166 166
167 this.form.patchValue({ 167 this.form.patchValue({
168 pluginData: this.video.pluginData 168 pluginData: this.videoEdit.pluginData
169 }) 169 })
170 } 170 }
171 171