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 --- .../shared/video-channel/video-channel.service.ts | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'client/src/app/shared/video-channel/video-channel.service.ts') diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts index 3533a0e9c..e1e3bf697 100644 --- a/client/src/app/shared/video-channel/video-channel.service.ts +++ b/client/src/app/shared/video-channel/video-channel.service.ts @@ -1,18 +1,13 @@ +import { catchError, map, tap } from 'rxjs/operators' import { Injectable } from '@angular/core' -import 'rxjs/add/operator/catch' -import 'rxjs/add/operator/map' -import { Observable } from 'rxjs/Observable' +import { Observable, ReplaySubject } from 'rxjs' import { RestExtractor } from '../rest/rest-extractor.service' -import { RestService } from '../rest/rest.service' import { HttpClient } from '@angular/common/http' import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos' import { AccountService } from '../account/account.service' import { ResultList } from '../../../../../shared' import { VideoChannel } from './video-channel.model' -import { ReplaySubject } from 'rxjs/ReplaySubject' import { environment } from '../../../environments/environment' -import { UserService } from '@app/+admin/users/shared/user.service' -import { User } from '@app/shared' @Injectable() export class VideoChannelService { @@ -22,39 +17,48 @@ export class VideoChannelService { constructor ( private authHttp: HttpClient, - private restExtractor: RestExtractor, - private restService: RestService + private restExtractor: RestExtractor ) {} getVideoChannel (videoChannelUUID: string) { return this.authHttp.get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID) - .map(videoChannelHash => new VideoChannel(videoChannelHash)) - .do(videoChannel => this.videoChannelLoaded.next(videoChannel)) - .catch((res) => this.restExtractor.handleError(res)) + .pipe( + map(videoChannelHash => new VideoChannel(videoChannelHash)), + tap(videoChannel => this.videoChannelLoaded.next(videoChannel)), + catchError(res => this.restExtractor.handleError(res)) + ) } listAccountVideoChannels (accountId: number): Observable> { return this.authHttp.get>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels') - .map(res => this.extractVideoChannels(res)) - .catch((res) => this.restExtractor.handleError(res)) + .pipe( + map(res => this.extractVideoChannels(res)), + catchError((res) => this.restExtractor.handleError(res)) + ) } createVideoChannel (videoChannel: VideoChannelCreate) { return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel) - .map(this.restExtractor.extractDataBool) - .catch(err => this.restExtractor.handleError(err)) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(err => this.restExtractor.handleError(err)) + ) } updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) { return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel) - .map(this.restExtractor.extractDataBool) - .catch(err => this.restExtractor.handleError(err)) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(err => this.restExtractor.handleError(err)) + ) } removeVideoChannel (videoChannel: VideoChannel) { return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid) - .map(this.restExtractor.extractDataBool) - .catch(err => this.restExtractor.handleError(err)) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(err => this.restExtractor.handleError(err)) + ) } private extractVideoChannels (result: ResultList) { -- cgit v1.2.3