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/+admin/follows/shared | |
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/+admin/follows/shared')
-rw-r--r-- | client/src/app/+admin/follows/shared/follow.service.ts | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts index 089be9d64..5897e64ca 100644 --- a/client/src/app/+admin/follows/shared/follow.service.ts +++ b/client/src/app/+admin/follows/shared/follow.service.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
1 | import { HttpClient, HttpParams } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
2 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
3 | import { SortMeta } from 'primeng/primeng' | 4 | import { SortMeta } from 'primeng/primeng' |
4 | import 'rxjs/add/operator/catch' | 5 | import { Observable } from 'rxjs' |
5 | import 'rxjs/add/operator/map' | ||
6 | import { Observable } from 'rxjs/Observable' | ||
7 | import { AccountFollow, ResultList } from '../../../../../../shared' | 6 | import { AccountFollow, ResultList } from '../../../../../../shared' |
8 | import { environment } from '../../../../environments/environment' | 7 | import { environment } from '../../../../environments/environment' |
9 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | 8 | import { RestExtractor, RestPagination, RestService } from '../../../shared' |
@@ -16,24 +15,29 @@ export class FollowService { | |||
16 | private authHttp: HttpClient, | 15 | private authHttp: HttpClient, |
17 | private restService: RestService, | 16 | private restService: RestService, |
18 | private restExtractor: RestExtractor | 17 | private restExtractor: RestExtractor |
19 | ) {} | 18 | ) { |
19 | } | ||
20 | 20 | ||
21 | getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { | 21 | getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { |
22 | let params = new HttpParams() | 22 | let params = new HttpParams() |
23 | params = this.restService.addRestGetParams(params, pagination, sort) | 23 | params = this.restService.addRestGetParams(params, pagination, sort) |
24 | 24 | ||
25 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) | 25 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) |
26 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 26 | .pipe( |
27 | .catch(res => this.restExtractor.handleError(res)) | 27 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
28 | catchError(res => this.restExtractor.handleError(res)) | ||
29 | ) | ||
28 | } | 30 | } |
29 | 31 | ||
30 | getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { | 32 | getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> { |
31 | let params = new HttpParams() | 33 | let params = new HttpParams() |
32 | params = this.restService.addRestGetParams(params, pagination, sort) | 34 | params = this.restService.addRestGetParams(params, pagination, sort) |
33 | 35 | ||
34 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) | 36 | return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) |
35 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 37 | .pipe( |
36 | .catch(res => this.restExtractor.handleError(res)) | 38 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
39 | catchError(res => this.restExtractor.handleError(res)) | ||
40 | ) | ||
37 | } | 41 | } |
38 | 42 | ||
39 | follow (notEmptyHosts: string[]) { | 43 | follow (notEmptyHosts: string[]) { |
@@ -42,13 +46,17 @@ export class FollowService { | |||
42 | } | 46 | } |
43 | 47 | ||
44 | return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body) | 48 | return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body) |
45 | .map(this.restExtractor.extractDataBool) | 49 | .pipe( |
46 | .catch(res => this.restExtractor.handleError(res)) | 50 | map(this.restExtractor.extractDataBool), |
51 | catchError(res => this.restExtractor.handleError(res)) | ||
52 | ) | ||
47 | } | 53 | } |
48 | 54 | ||
49 | unfollow (follow: AccountFollow) { | 55 | unfollow (follow: AccountFollow) { |
50 | return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host) | 56 | return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host) |
51 | .map(this.restExtractor.extractDataBool) | 57 | .pipe( |
52 | .catch(res => this.restExtractor.handleError(res)) | 58 | map(this.restExtractor.extractDataBool), |
59 | catchError(res => this.restExtractor.handleError(res)) | ||
60 | ) | ||
53 | } | 61 | } |
54 | } | 62 | } |