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 --- .../app/+admin/follows/shared/follow.service.ts | 34 +++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'client/src/app/+admin/follows/shared') 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 @@ +import { catchError, map } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { SortMeta } from 'primeng/primeng' -import 'rxjs/add/operator/catch' -import 'rxjs/add/operator/map' -import { Observable } from 'rxjs/Observable' +import { Observable } from 'rxjs' import { AccountFollow, ResultList } from '../../../../../../shared' import { environment } from '../../../../environments/environment' import { RestExtractor, RestPagination, RestService } from '../../../shared' @@ -16,24 +15,29 @@ export class FollowService { private authHttp: HttpClient, private restService: RestService, private restExtractor: RestExtractor - ) {} + ) { + } getFollowing (pagination: RestPagination, sort: SortMeta): Observable> { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/following', { params }) - .map(res => this.restExtractor.convertResultListDateToHuman(res)) - .catch(res => this.restExtractor.handleError(res)) + .pipe( + map(res => this.restExtractor.convertResultListDateToHuman(res)), + catchError(res => this.restExtractor.handleError(res)) + ) } getFollowers (pagination: RestPagination, sort: SortMeta): Observable> { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) - .map(res => this.restExtractor.convertResultListDateToHuman(res)) - .catch(res => this.restExtractor.handleError(res)) + return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) + .pipe( + map(res => this.restExtractor.convertResultListDateToHuman(res)), + catchError(res => this.restExtractor.handleError(res)) + ) } follow (notEmptyHosts: string[]) { @@ -42,13 +46,17 @@ export class FollowService { } return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body) - .map(this.restExtractor.extractDataBool) - .catch(res => this.restExtractor.handleError(res)) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(res => this.restExtractor.handleError(res)) + ) } unfollow (follow: AccountFollow) { return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host) - .map(this.restExtractor.extractDataBool) - .catch(res => this.restExtractor.handleError(res)) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(res => this.restExtractor.handleError(res)) + ) } } -- cgit v1.2.3