From 1378c0d343028f3d40d7d795422684ab9e6a1599 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Aug 2021 11:27:47 +0200 Subject: Fix client lint --- .../video-go-live.component.ts | 59 ++++++++--------- .../video-import-torrent.component.ts | 75 +++++++++++----------- .../video-import-url.component.ts | 18 +++--- .../video-add-components/video-upload.component.ts | 8 +-- .../+videos/+video-edit/video-update.component.ts | 63 +++++++++--------- 5 files changed, 113 insertions(+), 110 deletions(-) (limited to 'client/src/app/+videos/+video-edit') diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index db25dc6be..30c79594d 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -8,7 +8,7 @@ import { FormValidatorService } from '@app/shared/shared-forms' import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LiveVideoService } from '@app/shared/shared-video-live' import { LoadingBarService } from '@ngx-loading-bar/core' -import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy } from '@shared/models' +import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' import { VideoSend } from './video-send' @Component({ @@ -74,33 +74,34 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId }) this.form.patchValue(toPatch) - this.liveVideoService.goLive(video).subscribe( - res => { - this.videoId = res.video.id - this.videoUUID = res.video.uuid - this.isInUpdateForm = true + this.liveVideoService.goLive(video) + .subscribe({ + next: res => { + this.videoId = res.video.id + this.videoUUID = res.video.uuid + this.isInUpdateForm = true - this.firstStepDone.emit(name) + this.firstStepDone.emit(name) - this.fetchVideoLive() - }, + this.fetchVideoLive() + }, + + error: err => { + this.firstStepError.emit() - err => { - this.firstStepError.emit() + let message = err.message - let message = err.message + const error = err.body as PeerTubeProblemDocument - const error = err.body as PeerTubeProblemDocument + if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { + message = $localize`Cannot create live because this instance have too many created lives` + } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) { + message = $localize`Cannot create live because you created too many lives` + } - if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { - message = $localize`Cannot create live because this instance have too many created lives` - } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) { - message = $localize`Cannot create live because you created too many lives` + this.notifier.error(message) } - - this.notifier.error(message) - } - ) + }) } updateSecondStep () { @@ -123,19 +124,19 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView this.updateVideoAndCaptions(video), this.liveVideoService.updateLive(this.videoId, liveVideoUpdate) - ]).subscribe( - () => { + ]).subscribe({ + next: () => { this.notifier.success($localize`Live published.`) this.router.navigateByUrl(Video.buildWatchUrl(video)) }, - err => { + error: err => { this.error = err.message scrollToTop() console.error(err) } - ) + }) } getMaxLiveDuration () { @@ -148,15 +149,15 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView private fetchVideoLive () { this.liveVideoService.getVideoLive(this.videoId) - .subscribe( - liveVideo => { + .subscribe({ + next: liveVideo => { this.liveVideo = liveVideo }, - err => { + error: err => { this.firstStepError.emit() this.notifier.error(err.message) } - ) + }) } } 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 62aaeb019..fef1f5d65 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 @@ -88,40 +88,41 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af this.loadingBar.useRef().start() - this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( - res => { - this.loadingBar.useRef().complete() - this.firstStepDone.emit(res.video.name) - this.isImportingVideo = false - this.hasImportedVideo = true - - this.video = new VideoEdit(Object.assign(res.video, { - commentsEnabled: videoUpdate.commentsEnabled, - downloadEnabled: videoUpdate.downloadEnabled, - privacy: { id: this.firstStepPrivacyId }, - support: null, - thumbnailUrl: null, - previewUrl: null - })) - - hydrateFormFromVideo(this.form, this.video, false) - }, - - err => { - this.loadingBar.useRef().complete() - this.isImportingVideo = false - this.firstStepError.emit() - - let message = err.message - - const error = err.body as PeerTubeProblemDocument - if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { - message = $localize`Torrents with only 1 file are supported.` - } + this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate) + .subscribe({ + next: res => { + this.loadingBar.useRef().complete() + this.firstStepDone.emit(res.video.name) + this.isImportingVideo = false + this.hasImportedVideo = true + + this.video = new VideoEdit(Object.assign(res.video, { + commentsEnabled: videoUpdate.commentsEnabled, + downloadEnabled: videoUpdate.downloadEnabled, + privacy: { id: this.firstStepPrivacyId }, + support: null, + thumbnailUrl: null, + previewUrl: null + })) + + hydrateFormFromVideo(this.form, this.video, false) + }, + + error: err => { + this.loadingBar.useRef().complete() + this.isImportingVideo = false + this.firstStepError.emit() + + let message = err.message + + const error = err.body as PeerTubeProblemDocument + if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { + message = $localize`Torrents with only 1 file are supported.` + } - this.notifier.error(message) - } - ) + this.notifier.error(message) + } + }) } updateSecondStep () { @@ -135,19 +136,19 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af // Update the video this.updateVideoAndCaptions(this.video) - .subscribe( - () => { + .subscribe({ + next: () => { this.isUpdatingVideo = false this.notifier.success($localize`Video to import updated.`) this.router.navigate([ '/my-library', 'video-imports' ]) }, - err => { + error: err => { this.error = err.message scrollToTop() console.error(err) } - ) + }) } } 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 3243b4d38..e1893b28f 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 @@ -6,7 +6,7 @@ import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers' import { FormValidatorService } from '@app/shared/shared-forms' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { VideoPrivacy, VideoUpdate } from '@shared/models' +import { VideoUpdate } from '@shared/models' import { hydrateFormFromVideo } from '../shared/video-edit-utils' import { VideoSend } from './video-send' @@ -86,8 +86,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV ) }) ) - .subscribe( - ({ video, videoCaptions }) => { + .subscribe({ + next: ({ video, videoCaptions }) => { this.loadingBar.useRef().complete() this.firstStepDone.emit(video.name) this.isImportingVideo = false @@ -117,13 +117,13 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV hydrateFormFromVideo(this.form, this.video, true) }, - err => { + error: err => { this.loadingBar.useRef().complete() this.isImportingVideo = false this.firstStepError.emit() this.notifier.error(err.message) } - ) + }) } updateSecondStep () { @@ -137,19 +137,19 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV // Update the video this.updateVideoAndCaptions(this.video) - .subscribe( - () => { + .subscribe({ + next: () => { this.isUpdatingVideo = false this.notifier.success($localize`Video to import updated.`) this.router.navigate([ '/my-library', 'video-imports' ]) }, - err => { + error: err => { this.error = err.message scrollToTop() console.error(err) } - ) + }) } } diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index 189bc9669..b8cb4fa1e 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -240,8 +240,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.isUpdatingVideo = true this.updateVideoAndCaptions(video) - .subscribe( - () => { + .subscribe({ + next: () => { this.isUpdatingVideo = false this.isUploadingVideo = false @@ -249,12 +249,12 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.router.navigateByUrl(Video.buildWatchUrl(video)) }, - err => { + error: err => { this.error = err.message scrollToTop() console.error(err) } - ) + }) } private getInputVideoFile () { 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 1534eee82..95336dc75 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -47,34 +47,35 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.route.data .pipe(map(data => data.videoData)) - .subscribe(({ video, videoChannels, videoCaptions, liveVideo }) => { - this.video = new VideoEdit(video) - this.videoDetails = video - - this.userVideoChannels = videoChannels - this.videoCaptions = videoCaptions - this.liveVideo = liveVideo - - this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE - - // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout - setTimeout(() => { - hydrateFormFromVideo(this.form, this.video, true) - - if (this.liveVideo) { - this.form.patchValue({ - saveReplay: this.liveVideo.saveReplay, - permanentLive: this.liveVideo.permanentLive - }) - } - }) - }, + .subscribe({ + next: ({ video, videoChannels, videoCaptions, liveVideo }) => { + this.video = new VideoEdit(video) + this.videoDetails = video + + this.userVideoChannels = videoChannels + this.videoCaptions = videoCaptions + this.liveVideo = liveVideo + + this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE + + // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout + setTimeout(() => { + hydrateFormFromVideo(this.form, this.video, true) + + if (this.liveVideo) { + this.form.patchValue({ + saveReplay: this.liveVideo.saveReplay, + permanentLive: this.liveVideo.permanentLive + }) + } + }) + }, - err => { - console.error(err) - this.notifier.error(err.message) - } - ) + error: err => { + console.error(err) + this.notifier.error(err.message) + } + }) } @HostListener('window:beforeunload', [ '$event' ]) @@ -150,8 +151,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) }) ) - .subscribe( - () => { + .subscribe({ + next: () => { this.updateDone = true this.isUpdatingVideo = false this.loadingBar.useRef().complete() @@ -159,13 +160,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.router.navigateByUrl(Video.buildWatchUrl(this.video)) }, - err => { + error: err => { this.loadingBar.useRef().complete() this.isUpdatingVideo = false this.notifier.error(err.message) console.error(err) } - ) + }) } hydratePluginFieldsFromVideo () { -- cgit v1.2.3