From db400f447a9f7aae1c56fa25396e93069744483f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 May 2018 11:55:51 +0200 Subject: Upgrade to rxjs 6 --- .../+video-edit/shared/video-edit.component.ts | 1 - .../+video-edit/shared/video-image.component.ts | 2 - .../app/videos/+video-edit/video-add.component.ts | 3 +- .../videos/+video-edit/video-update.component.ts | 61 +++++++++++----------- 4 files changed, 32 insertions(+), 35 deletions(-) (limited to 'client/src/app/videos/+video-edit') diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index 77e984855..eab0a898e 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts @@ -3,7 +3,6 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms' import { ActivatedRoute, Router } from '@angular/router' import { VIDEO_IMAGE, VIDEO_SUPPORT } from '@app/shared' import { NotificationsService } from 'angular2-notifications' -import 'rxjs/add/observable/forkJoin' import { ServerService } from '../../../core/server' import { VIDEO_CHANNEL } from '../../../shared/forms/form-validators' import { ValidatorMessage } from '../../../shared/forms/form-validators/validator-message' diff --git a/client/src/app/videos/+video-edit/shared/video-image.component.ts b/client/src/app/videos/+video-edit/shared/video-image.component.ts index 3f5705a92..df6565857 100644 --- a/client/src/app/videos/+video-edit/shared/video-image.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-image.component.ts @@ -2,7 +2,6 @@ import { Component, forwardRef, Input } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' import { ServerService } from '@app/core' -import 'rxjs/add/observable/forkJoin' @Component({ selector: 'my-video-image', @@ -16,7 +15,6 @@ import 'rxjs/add/observable/forkJoin' } ] }) - export class VideoImageComponent implements ControlValueAccessor { @Input() inputLabel: string @Input() inputName: string 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 fa967018d..41d14573c 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -7,7 +7,7 @@ import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard. import { LoadingBarService } from '@ngx-loading-bar/core' import { NotificationsService } from 'angular2-notifications' import { BytesPipe } from 'ngx-pipes' -import { Subscription } from 'rxjs/Subscription' +import { Subscription } from 'rxjs' import { VideoPrivacy } from '../../../../../shared/models/videos' import { AuthService, ServerService } from '../../core' import { FormReactive } from '../../shared' @@ -24,7 +24,6 @@ import { VideoService } from '../../shared/video/video.service' './video-add.component.scss' ] }) - export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate { @ViewChild('videofileInput') videofileInput 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 73e2764c6..b1d80bcaa 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -1,9 +1,9 @@ +import { map, switchMap } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { FormBuilder, FormGroup } from '@angular/forms' import { ActivatedRoute, Router } from '@angular/router' import { LoadingBarService } from '@ngx-loading-bar/core' import { NotificationsService } from 'angular2-notifications' -import 'rxjs/add/observable/forkJoin' import { VideoPrivacy } from '../../../../../shared/models/videos' import { ServerService } from '../../core' import { AuthService } from '../../core/auth' @@ -18,7 +18,6 @@ import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils' styleUrls: [ './shared/video-edit.component.scss' ], templateUrl: './video-update.component.html' }) - export class VideoUpdateComponent extends FormReactive implements OnInit { video: VideoEdit @@ -53,38 +52,40 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.serverService.videoPrivaciesLoaded .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies()) - const uuid: string = this.route.snapshot.params['uuid'] + const uuid: string = this.route.snapshot.params[ 'uuid' ] this.videoService.getVideo(uuid) - .switchMap(video => { - return this.videoService - .loadCompleteDescription(video.descriptionPath) - .map(description => Object.assign(video, { description })) - }) - .subscribe( - video => { - this.video = new VideoEdit(video) - - populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) - .catch(err => console.error(err)) - - // We cannot set private a video that was not private - if (video.privacy.id !== VideoPrivacy.PRIVATE) { - const newVideoPrivacies = [] - for (const p of this.videoPrivacies) { - if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p) + .pipe( + switchMap(video => { + return this.videoService + .loadCompleteDescription(video.descriptionPath) + .pipe(map(description => Object.assign(video, { description }))) + }) + ) + .subscribe( + video => { + this.video = new VideoEdit(video) + + populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) + .catch(err => console.error(err)) + + // We cannot set private a video that was not private + if (video.privacy.id !== VideoPrivacy.PRIVATE) { + const newVideoPrivacies = [] + for (const p of this.videoPrivacies) { + if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p) + } + + this.videoPrivacies = newVideoPrivacies } - this.videoPrivacies = newVideoPrivacies - } + this.hydrateFormFromVideo() + }, - this.hydrateFormFromVideo() - }, - - err => { - console.error(err) - this.notificationsService.error('Error', err.message) - } - ) + err => { + console.error(err) + this.notificationsService.error('Error', err.message) + } + ) } checkForm () { -- cgit v1.2.3