]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/account/account.service.ts
Try to improve notification i18n translations
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / account / account.service.ts
index 8c66ae04ab169461f262fed1a96cc3ecd848f864..6b261cf532083c976ac337b0667903c3e3055390 100644 (file)
@@ -1,14 +1,11 @@
+import { map, tap, catchError } from 'rxjs/operators'
 import { Injectable } from '@angular/core'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
 import { environment } from '../../../environments/environment'
-import { Observable } from 'rxjs/Observable'
+import { Observable, ReplaySubject } from 'rxjs'
 import { Account } from '@app/shared/account/account.model'
 import { RestExtractor } from '@app/shared/rest/rest-extractor.service'
-import { RestService } from '@app/shared/rest/rest.service'
 import { HttpClient } from '@angular/common/http'
 import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
-import { ReplaySubject } from 'rxjs/ReplaySubject'
 
 @Injectable()
 export class AccountService {
@@ -18,14 +15,15 @@ export class AccountService {
 
   constructor (
     private authHttp: HttpClient,
-    private restExtractor: RestExtractor,
-    private restService: RestService
+    private restExtractor: RestExtractor
   ) {}
 
-  getAccount (id: number): Observable<Account> {
+  getAccount (id: number | string): Observable<Account> {
     return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id)
-               .map(accountHash => new Account(accountHash))
-               .do(account => this.accountLoaded.next(account))
-               .catch((res) => this.restExtractor.handleError(res))
+               .pipe(
+                 map(accountHash => new Account(accountHash)),
+                 tap(account => this.accountLoaded.next(account)),
+                 catchError(res => this.restExtractor.handleError(res))
+               )
   }
 }