diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-15 11:55:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-16 09:42:54 +0200 |
commit | db400f447a9f7aae1c56fa25396e93069744483f (patch) | |
tree | f45af832a5d3f4eebafd2f885b7413d9f84fa374 /client/src/app/shared/video-channel | |
parent | 54c3a22faa04bf13eea37f39be9149fc5eb95737 (diff) | |
download | PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.tar.gz PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.tar.zst PeerTube-db400f447a9f7aae1c56fa25396e93069744483f.zip |
Upgrade to rxjs 6
Diffstat (limited to 'client/src/app/shared/video-channel')
-rw-r--r-- | client/src/app/shared/video-channel/video-channel.service.ts | 44 |
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 @@ | |||
1 | import { catchError, map, tap } from 'rxjs/operators' | ||
1 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
2 | import 'rxjs/add/operator/catch' | 3 | import { Observable, ReplaySubject } from 'rxjs' |
3 | import 'rxjs/add/operator/map' | ||
4 | import { Observable } from 'rxjs/Observable' | ||
5 | import { RestExtractor } from '../rest/rest-extractor.service' | 4 | import { RestExtractor } from '../rest/rest-extractor.service' |
6 | import { RestService } from '../rest/rest.service' | ||
7 | import { HttpClient } from '@angular/common/http' | 5 | import { HttpClient } from '@angular/common/http' |
8 | import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos' | 6 | import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos' |
9 | import { AccountService } from '../account/account.service' | 7 | import { AccountService } from '../account/account.service' |
10 | import { ResultList } from '../../../../../shared' | 8 | import { ResultList } from '../../../../../shared' |
11 | import { VideoChannel } from './video-channel.model' | 9 | import { VideoChannel } from './video-channel.model' |
12 | import { ReplaySubject } from 'rxjs/ReplaySubject' | ||
13 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
14 | import { UserService } from '@app/+admin/users/shared/user.service' | ||
15 | import { User } from '@app/shared' | ||
16 | 11 | ||
17 | @Injectable() | 12 | @Injectable() |
18 | export class VideoChannelService { | 13 | export 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>) { |