aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video-channel/video-channel.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-15 11:55:51 +0200
committerChocobozzz <me@florianbigard.com>2018-05-16 09:42:54 +0200
commitdb400f447a9f7aae1c56fa25396e93069744483f (patch)
treef45af832a5d3f4eebafd2f885b7413d9f84fa374 /client/src/app/shared/video-channel/video-channel.service.ts
parent54c3a22faa04bf13eea37f39be9149fc5eb95737 (diff)
downloadPeerTube-db400f447a9f7aae1c56fa25396e93069744483f.tar.gz
PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.tar.zst
PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.zip
Upgrade to rxjs 6
Diffstat (limited to 'client/src/app/shared/video-channel/video-channel.service.ts')
-rw-r--r--client/src/app/shared/video-channel/video-channel.service.ts44
1 files changed, 24 insertions, 20 deletions
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 @@
1import { catchError, map, tap } from 'rxjs/operators'
1import { Injectable } from '@angular/core' 2import { Injectable } from '@angular/core'
2import 'rxjs/add/operator/catch' 3import { Observable, ReplaySubject } from 'rxjs'
3import 'rxjs/add/operator/map'
4import { Observable } from 'rxjs/Observable'
5import { RestExtractor } from '../rest/rest-extractor.service' 4import { RestExtractor } from '../rest/rest-extractor.service'
6import { RestService } from '../rest/rest.service'
7import { HttpClient } from '@angular/common/http' 5import { HttpClient } from '@angular/common/http'
8import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos' 6import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos'
9import { AccountService } from '../account/account.service' 7import { AccountService } from '../account/account.service'
10import { ResultList } from '../../../../../shared' 8import { ResultList } from '../../../../../shared'
11import { VideoChannel } from './video-channel.model' 9import { VideoChannel } from './video-channel.model'
12import { ReplaySubject } from 'rxjs/ReplaySubject'
13import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
14import { UserService } from '@app/+admin/users/shared/user.service'
15import { User } from '@app/shared'
16 11
17@Injectable() 12@Injectable()
18export class VideoChannelService { 13export class VideoChannelService {
@@ -22,39 +17,48 @@ export class VideoChannelService {
22 17
23 constructor ( 18 constructor (
24 private authHttp: HttpClient, 19 private authHttp: HttpClient,
25 private restExtractor: RestExtractor, 20 private restExtractor: RestExtractor
26 private restService: RestService
27 ) {} 21 ) {}
28 22
29 getVideoChannel (videoChannelUUID: string) { 23 getVideoChannel (videoChannelUUID: string) {
30 return this.authHttp.get<VideoChannel>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID) 24 return this.authHttp.get<VideoChannel>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID)
31 .map(videoChannelHash => new VideoChannel(videoChannelHash)) 25 .pipe(
32 .do(videoChannel => this.videoChannelLoaded.next(videoChannel)) 26 map(videoChannelHash => new VideoChannel(videoChannelHash)),
33 .catch((res) => this.restExtractor.handleError(res)) 27 tap(videoChannel => this.videoChannelLoaded.next(videoChannel)),
28 catchError(res => this.restExtractor.handleError(res))
29 )
34 } 30 }
35 31
36 listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> { 32 listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {
37 return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels') 33 return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')
38 .map(res => this.extractVideoChannels(res)) 34 .pipe(
39 .catch((res) => this.restExtractor.handleError(res)) 35 map(res => this.extractVideoChannels(res)),
36 catchError((res) => this.restExtractor.handleError(res))
37 )
40 } 38 }
41 39
42 createVideoChannel (videoChannel: VideoChannelCreate) { 40 createVideoChannel (videoChannel: VideoChannelCreate) {
43 return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel) 41 return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel)
44 .map(this.restExtractor.extractDataBool) 42 .pipe(
45 .catch(err => this.restExtractor.handleError(err)) 43 map(this.restExtractor.extractDataBool),
44 catchError(err => this.restExtractor.handleError(err))
45 )
46 } 46 }
47 47
48 updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) { 48 updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) {
49 return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel) 49 return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel)
50 .map(this.restExtractor.extractDataBool) 50 .pipe(
51 .catch(err => this.restExtractor.handleError(err)) 51 map(this.restExtractor.extractDataBool),
52 catchError(err => this.restExtractor.handleError(err))
53 )
52 } 54 }
53 55
54 removeVideoChannel (videoChannel: VideoChannel) { 56 removeVideoChannel (videoChannel: VideoChannel) {
55 return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid) 57 return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid)
56 .map(this.restExtractor.extractDataBool) 58 .pipe(
57 .catch(err => this.restExtractor.handleError(err)) 59 map(this.restExtractor.extractDataBool),
60 catchError(err => this.restExtractor.handleError(err))
61 )
58 } 62 }
59 63
60 private extractVideoChannels (result: ResultList<VideoChannelServer>) { 64 private extractVideoChannels (result: ResultList<VideoChannelServer>) {