diff options
Diffstat (limited to 'client/src/app/shared')
13 files changed, 208 insertions, 169 deletions
diff --git a/client/src/app/shared/account/account.service.ts b/client/src/app/shared/account/account.service.ts index 8c66ae04a..20e52d946 100644 --- a/client/src/app/shared/account/account.service.ts +++ b/client/src/app/shared/account/account.service.ts | |||
@@ -1,14 +1,11 @@ | |||
1 | import { map, tap, catchError } from 'rxjs/operators' | ||
1 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
2 | import 'rxjs/add/operator/catch' | ||
3 | import 'rxjs/add/operator/map' | ||
4 | import { environment } from '../../../environments/environment' | 3 | import { environment } from '../../../environments/environment' |
5 | import { Observable } from 'rxjs/Observable' | 4 | import { Observable, ReplaySubject } from 'rxjs' |
6 | import { Account } from '@app/shared/account/account.model' | 5 | import { Account } from '@app/shared/account/account.model' |
7 | import { RestExtractor } from '@app/shared/rest/rest-extractor.service' | 6 | import { RestExtractor } from '@app/shared/rest/rest-extractor.service' |
8 | import { RestService } from '@app/shared/rest/rest.service' | ||
9 | import { HttpClient } from '@angular/common/http' | 7 | import { HttpClient } from '@angular/common/http' |
10 | import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model' | 8 | import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model' |
11 | import { ReplaySubject } from 'rxjs/ReplaySubject' | ||
12 | 9 | ||
13 | @Injectable() | 10 | @Injectable() |
14 | export class AccountService { | 11 | export class AccountService { |
@@ -18,14 +15,15 @@ export class AccountService { | |||
18 | 15 | ||
19 | constructor ( | 16 | constructor ( |
20 | private authHttp: HttpClient, | 17 | private authHttp: HttpClient, |
21 | private restExtractor: RestExtractor, | 18 | private restExtractor: RestExtractor |
22 | private restService: RestService | ||
23 | ) {} | 19 | ) {} |
24 | 20 | ||
25 | getAccount (id: number): Observable<Account> { | 21 | getAccount (id: number): Observable<Account> { |
26 | return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id) | 22 | return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id) |
27 | .map(accountHash => new Account(accountHash)) | 23 | .pipe( |
28 | .do(account => this.accountLoaded.next(account)) | 24 | map(accountHash => new Account(accountHash)), |
29 | .catch((res) => this.restExtractor.handleError(res)) | 25 | tap(account => this.accountLoaded.next(account)), |
26 | catchError(res => this.restExtractor.handleError(res)) | ||
27 | ) | ||
30 | } | 28 | } |
31 | } | 29 | } |
diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts index 37d84cb6e..f820dc3c4 100644 --- a/client/src/app/shared/actor/actor.model.ts +++ b/client/src/app/shared/actor/actor.model.ts | |||
@@ -10,8 +10,8 @@ export abstract class Actor implements ActorServer { | |||
10 | host: string | 10 | host: string |
11 | followingCount: number | 11 | followingCount: number |
12 | followersCount: number | 12 | followersCount: number |
13 | createdAt: Date | 13 | createdAt: Date | string |
14 | updatedAt: Date | 14 | updatedAt: Date | string |
15 | avatar: Avatar | 15 | avatar: Avatar |
16 | 16 | ||
17 | avatarUrl: string | 17 | avatarUrl: string |
@@ -41,8 +41,8 @@ export abstract class Actor implements ActorServer { | |||
41 | this.host = hash.host | 41 | this.host = hash.host |
42 | this.followingCount = hash.followingCount | 42 | this.followingCount = hash.followingCount |
43 | this.followersCount = hash.followersCount | 43 | this.followersCount = hash.followersCount |
44 | this.createdAt = new Date(hash.createdAt) | 44 | this.createdAt = new Date(hash.createdAt.toString()) |
45 | this.updatedAt = new Date(hash.updatedAt) | 45 | this.updatedAt = new Date(hash.updatedAt.toString()) |
46 | this.avatar = hash.avatar | 46 | this.avatar = hash.avatar |
47 | 47 | ||
48 | this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this) | 48 | this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this) |
diff --git a/client/src/app/shared/auth/auth-interceptor.service.ts b/client/src/app/shared/auth/auth-interceptor.service.ts index efcfc452b..bb236bf8c 100644 --- a/client/src/app/shared/auth/auth-interceptor.service.ts +++ b/client/src/app/shared/auth/auth-interceptor.service.ts | |||
@@ -1,14 +1,8 @@ | |||
1 | import { Observable, throwError as observableThrowError } from 'rxjs' | ||
2 | import { catchError, switchMap } from 'rxjs/operators' | ||
1 | import { Injectable, Injector } from '@angular/core' | 3 | import { Injectable, Injector } from '@angular/core' |
2 | import { | 4 | import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http' |
3 | HttpInterceptor, | ||
4 | HttpRequest, | ||
5 | HttpEvent, | ||
6 | HttpHandler, HTTP_INTERCEPTORS | ||
7 | } from '@angular/common/http' | ||
8 | import { Observable } from 'rxjs/Observable' | ||
9 | |||
10 | import { AuthService } from '../../core' | 5 | import { AuthService } from '../../core' |
11 | import 'rxjs/add/operator/switchMap' | ||
12 | 6 | ||
13 | @Injectable() | 7 | @Injectable() |
14 | export class AuthInterceptor implements HttpInterceptor { | 8 | export class AuthInterceptor implements HttpInterceptor { |
@@ -27,22 +21,26 @@ export class AuthInterceptor implements HttpInterceptor { | |||
27 | // Pass on the cloned request instead of the original request | 21 | // Pass on the cloned request instead of the original request |
28 | // Catch 401 errors (refresh token expired) | 22 | // Catch 401 errors (refresh token expired) |
29 | return next.handle(authReq) | 23 | return next.handle(authReq) |
30 | .catch(err => { | 24 | .pipe( |
31 | if (err.status === 401 && err.error && err.error.code === 'invalid_token') { | 25 | catchError(err => { |
32 | return this.handleTokenExpired(req, next) | 26 | if (err.status === 401 && err.error && err.error.code === 'invalid_token') { |
33 | } | 27 | return this.handleTokenExpired(req, next) |
34 | 28 | } | |
35 | return Observable.throw(err) | 29 | |
36 | }) | 30 | return observableThrowError(err) |
31 | }) | ||
32 | ) | ||
37 | } | 33 | } |
38 | 34 | ||
39 | private handleTokenExpired (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | 35 | private handleTokenExpired (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
40 | return this.authService.refreshAccessToken() | 36 | return this.authService.refreshAccessToken() |
41 | .switchMap(() => { | 37 | .pipe( |
42 | const authReq = this.cloneRequestWithAuth(req) | 38 | switchMap(() => { |
39 | const authReq = this.cloneRequestWithAuth(req) | ||
43 | 40 | ||
44 | return next.handle(authReq) | 41 | return next.handle(authReq) |
45 | }) | 42 | }) |
43 | ) | ||
46 | } | 44 | } |
47 | 45 | ||
48 | private cloneRequestWithAuth (req: HttpRequest<any>) { | 46 | private cloneRequestWithAuth (req: HttpRequest<any>) { |
diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts index 928a63b28..dcc85f3cd 100644 --- a/client/src/app/shared/forms/markdown-textarea.component.ts +++ b/client/src/app/shared/forms/markdown-textarea.component.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import { debounceTime, distinctUntilChanged } from 'rxjs/operators' | ||
1 | import { Component, forwardRef, Input, OnInit } from '@angular/core' | 2 | import { Component, forwardRef, Input, OnInit } from '@angular/core' |
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 3 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import 'rxjs/add/operator/debounceTime' | ||
4 | import 'rxjs/add/operator/distinctUntilChanged' | ||
5 | import { isInSmallView } from '@app/shared/misc/utils' | 4 | import { isInSmallView } from '@app/shared/misc/utils' |
6 | import { MarkdownService } from '@app/videos/shared' | 5 | import { MarkdownService } from '@app/videos/shared' |
7 | import { Subject } from 'rxjs/Subject' | 6 | import { Subject } from 'rxjs' |
8 | import truncate from 'lodash-es/truncate' | 7 | import truncate from 'lodash-es/truncate' |
9 | 8 | ||
10 | @Component({ | 9 | @Component({ |
@@ -40,9 +39,11 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit { | |||
40 | 39 | ||
41 | ngOnInit () { | 40 | ngOnInit () { |
42 | this.contentChanged | 41 | this.contentChanged |
43 | .debounceTime(150) | 42 | .pipe( |
44 | .distinctUntilChanged() | 43 | debounceTime(150), |
45 | .subscribe(() => this.updatePreviews()) | 44 | distinctUntilChanged() |
45 | ) | ||
46 | .subscribe(() => this.updatePreviews()) | ||
46 | 47 | ||
47 | this.contentChanged.next(this.content) | 48 | this.contentChanged.next(this.content) |
48 | 49 | ||
diff --git a/client/src/app/shared/guards/can-deactivate-guard.service.ts b/client/src/app/shared/guards/can-deactivate-guard.service.ts index c3b5f37f8..550dd656e 100644 --- a/client/src/app/shared/guards/can-deactivate-guard.service.ts +++ b/client/src/app/shared/guards/can-deactivate-guard.service.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router' |
3 | import { Observable } from 'rxjs/Observable' | 3 | import { Observable } from 'rxjs' |
4 | import { ConfirmService } from '../../core/index' | 4 | import { ConfirmService } from '../../core/index' |
5 | 5 | ||
6 | export interface CanComponentDeactivate { | 6 | export interface CanComponentDeactivate { |
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 8ed24c727..4cfe28536 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { HttpErrorResponse } from '@angular/common/http' | 1 | import { of, throwError as observableThrowError } from 'rxjs' |
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { dateToHuman } from '@app/shared/misc/utils' | 3 | import { dateToHuman } from '@app/shared/misc/utils' |
4 | import { Observable } from 'rxjs/Observable' | ||
5 | import { ResultList } from '../../../../../shared' | 4 | import { ResultList } from '../../../../../shared' |
6 | 5 | ||
7 | @Injectable() | 6 | @Injectable() |
@@ -86,6 +85,8 @@ export class RestExtractor { | |||
86 | errorObj.body = err.error | 85 | errorObj.body = err.error |
87 | } | 86 | } |
88 | 87 | ||
89 | return Observable.throw(errorObj) | 88 | observableThrowError(errorObj) |
89 | |||
90 | return of(undefined) | ||
90 | } | 91 | } |
91 | } | 92 | } |
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index adb840cec..4843be618 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
1 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
2 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
3 | import 'rxjs/add/operator/catch' | ||
4 | import 'rxjs/add/operator/map' | ||
5 | import { UserCreate, UserUpdateMe } from '../../../../../shared' | 4 | import { UserCreate, UserUpdateMe } from '../../../../../shared' |
6 | import { environment } from '../../../environments/environment' | 5 | import { environment } from '../../../environments/environment' |
7 | import { RestExtractor } from '../rest' | 6 | import { RestExtractor } from '../rest' |
@@ -13,7 +12,8 @@ export class UserService { | |||
13 | constructor ( | 12 | constructor ( |
14 | private authHttp: HttpClient, | 13 | private authHttp: HttpClient, |
15 | private restExtractor: RestExtractor | 14 | private restExtractor: RestExtractor |
16 | ) {} | 15 | ) { |
16 | } | ||
17 | 17 | ||
18 | changePassword (newPassword: string) { | 18 | changePassword (newPassword: string) { |
19 | const url = UserService.BASE_USERS_URL + 'me' | 19 | const url = UserService.BASE_USERS_URL + 'me' |
@@ -22,44 +22,52 @@ export class UserService { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | return this.authHttp.put(url, body) | 24 | return this.authHttp.put(url, body) |
25 | .map(this.restExtractor.extractDataBool) | 25 | .pipe( |
26 | .catch(res => this.restExtractor.handleError(res)) | 26 | map(this.restExtractor.extractDataBool), |
27 | catchError(res => this.restExtractor.handleError(res)) | ||
28 | ) | ||
27 | } | 29 | } |
28 | 30 | ||
29 | updateMyProfile (profile: UserUpdateMe) { | 31 | updateMyProfile (profile: UserUpdateMe) { |
30 | const url = UserService.BASE_USERS_URL + 'me' | 32 | const url = UserService.BASE_USERS_URL + 'me' |
31 | 33 | ||
32 | return this.authHttp.put(url, profile) | 34 | return this.authHttp.put(url, profile) |
33 | .map(this.restExtractor.extractDataBool) | 35 | .pipe( |
34 | .catch(res => this.restExtractor.handleError(res)) | 36 | map(this.restExtractor.extractDataBool), |
37 | catchError(res => this.restExtractor.handleError(res)) | ||
38 | ) | ||
35 | } | 39 | } |
36 | 40 | ||
37 | changeAvatar (avatarForm: FormData) { | 41 | changeAvatar (avatarForm: FormData) { |
38 | const url = UserService.BASE_USERS_URL + 'me/avatar/pick' | 42 | const url = UserService.BASE_USERS_URL + 'me/avatar/pick' |
39 | 43 | ||
40 | return this.authHttp.post(url, avatarForm) | 44 | return this.authHttp.post(url, avatarForm) |
41 | .catch(this.restExtractor.handleError) | 45 | .pipe(catchError(this.restExtractor.handleError)) |
42 | } | 46 | } |
43 | 47 | ||
44 | signup (userCreate: UserCreate) { | 48 | signup (userCreate: UserCreate) { |
45 | return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate) | 49 | return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate) |
46 | .map(this.restExtractor.extractDataBool) | 50 | .pipe( |
47 | .catch(res => this.restExtractor.handleError(res)) | 51 | map(this.restExtractor.extractDataBool), |
52 | catchError(res => this.restExtractor.handleError(res)) | ||
53 | ) | ||
48 | } | 54 | } |
49 | 55 | ||
50 | getMyVideoQuotaUsed () { | 56 | getMyVideoQuotaUsed () { |
51 | const url = UserService.BASE_USERS_URL + '/me/video-quota-used' | 57 | const url = UserService.BASE_USERS_URL + '/me/video-quota-used' |
52 | 58 | ||
53 | return this.authHttp.get(url) | 59 | return this.authHttp.get(url) |
54 | .catch(res => this.restExtractor.handleError(res)) | 60 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
55 | } | 61 | } |
56 | 62 | ||
57 | askResetPassword (email: string) { | 63 | askResetPassword (email: string) { |
58 | const url = UserService.BASE_USERS_URL + '/ask-reset-password' | 64 | const url = UserService.BASE_USERS_URL + '/ask-reset-password' |
59 | 65 | ||
60 | return this.authHttp.post(url, { email }) | 66 | return this.authHttp.post(url, { email }) |
61 | .map(this.restExtractor.extractDataBool) | 67 | .pipe( |
62 | .catch(res => this.restExtractor.handleError(res)) | 68 | map(this.restExtractor.extractDataBool), |
69 | catchError(res => this.restExtractor.handleError(res)) | ||
70 | ) | ||
63 | } | 71 | } |
64 | 72 | ||
65 | resetPassword (userId: number, verificationString: string, password: string) { | 73 | resetPassword (userId: number, verificationString: string, password: string) { |
@@ -70,7 +78,9 @@ export class UserService { | |||
70 | } | 78 | } |
71 | 79 | ||
72 | return this.authHttp.post(url, body) | 80 | return this.authHttp.post(url, body) |
73 | .map(this.restExtractor.extractDataBool) | 81 | .pipe( |
74 | .catch(res => this.restExtractor.handleError(res)) | 82 | map(this.restExtractor.extractDataBool), |
83 | catchError(res => this.restExtractor.handleError(res)) | ||
84 | ) | ||
75 | } | 85 | } |
76 | } | 86 | } |
diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts index ae00c4c45..6fab3ef43 100644 --- a/client/src/app/shared/video-abuse/video-abuse.service.ts +++ b/client/src/app/shared/video-abuse/video-abuse.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/components/common/sortmeta' | 4 | import { SortMeta } from 'primeng/components/common/sortmeta' |
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 { ResultList, VideoAbuse } from '../../../../../shared' | 6 | import { ResultList, VideoAbuse } from '../../../../../shared' |
8 | import { environment } from '../../../environments/environment' | 7 | import { environment } from '../../../environments/environment' |
9 | import { RestExtractor, RestPagination, RestService } from '../rest' | 8 | import { RestExtractor, RestPagination, RestService } from '../rest' |
@@ -25,8 +24,10 @@ export class VideoAbuseService { | |||
25 | params = this.restService.addRestGetParams(params, pagination, sort) | 24 | params = this.restService.addRestGetParams(params, pagination, sort) |
26 | 25 | ||
27 | return this.authHttp.get<ResultList<VideoAbuse>>(url, { params }) | 26 | return this.authHttp.get<ResultList<VideoAbuse>>(url, { params }) |
28 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 27 | .pipe( |
29 | .catch(res => this.restExtractor.handleError(res)) | 28 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
29 | catchError(res => this.restExtractor.handleError(res)) | ||
30 | ) | ||
30 | } | 31 | } |
31 | 32 | ||
32 | reportVideo (id: number, reason: string) { | 33 | reportVideo (id: number, reason: string) { |
@@ -36,7 +37,9 @@ export class VideoAbuseService { | |||
36 | } | 37 | } |
37 | 38 | ||
38 | return this.authHttp.post(url, body) | 39 | return this.authHttp.post(url, body) |
39 | .map(this.restExtractor.extractDataBool) | 40 | .pipe( |
40 | .catch(res => this.restExtractor.handleError(res)) | 41 | map(this.restExtractor.extractDataBool), |
42 | catchError(res => this.restExtractor.handleError(res)) | ||
43 | ) | ||
41 | } | 44 | } |
42 | } | 45 | } |
diff --git a/client/src/app/shared/video-blacklist/video-blacklist.service.ts b/client/src/app/shared/video-blacklist/video-blacklist.service.ts index 14c8b5dc0..040d82c9a 100644 --- a/client/src/app/shared/video-blacklist/video-blacklist.service.ts +++ b/client/src/app/shared/video-blacklist/video-blacklist.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/components/common/sortmeta' | 4 | import { SortMeta } from 'primeng/components/common/sortmeta' |
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 { BlacklistedVideo, ResultList } from '../../../../../shared' | 6 | import { BlacklistedVideo, ResultList } from '../../../../../shared' |
8 | import { environment } from '../../../environments/environment' | 7 | import { environment } from '../../../environments/environment' |
9 | import { RestExtractor, RestPagination, RestService } from '../rest' | 8 | import { RestExtractor, RestPagination, RestService } from '../rest' |
@@ -23,19 +22,25 @@ export class VideoBlacklistService { | |||
23 | params = this.restService.addRestGetParams(params, pagination, sort) | 22 | params = this.restService.addRestGetParams(params, pagination, sort) |
24 | 23 | ||
25 | return this.authHttp.get<ResultList<BlacklistedVideo>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params }) | 24 | return this.authHttp.get<ResultList<BlacklistedVideo>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params }) |
26 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 25 | .pipe( |
27 | .catch(res => this.restExtractor.handleError(res)) | 26 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
27 | catchError(res => this.restExtractor.handleError(res)) | ||
28 | ) | ||
28 | } | 29 | } |
29 | 30 | ||
30 | removeVideoFromBlacklist (videoId: number) { | 31 | removeVideoFromBlacklist (videoId: number) { |
31 | return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist') | 32 | return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist') |
32 | .map(this.restExtractor.extractDataBool) | 33 | .pipe( |
33 | .catch(res => this.restExtractor.handleError(res)) | 34 | map(this.restExtractor.extractDataBool), |
35 | catchError(res => this.restExtractor.handleError(res)) | ||
36 | ) | ||
34 | } | 37 | } |
35 | 38 | ||
36 | blacklistVideo (videoId: number) { | 39 | blacklistVideo (videoId: number) { |
37 | return this.authHttp.post(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist', {}) | 40 | return this.authHttp.post(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist', {}) |
38 | .map(this.restExtractor.extractDataBool) | 41 | .pipe( |
39 | .catch(res => this.restExtractor.handleError(res)) | 42 | map(this.restExtractor.extractDataBool), |
43 | catchError(res => this.restExtractor.handleError(res)) | ||
44 | ) | ||
40 | } | 45 | } |
41 | } | 46 | } |
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>) { |
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index d8a4b03af..d47df4da4 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -1,13 +1,11 @@ | |||
1 | import { debounceTime } from 'rxjs/operators' | ||
1 | import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { Location } from '@angular/common' | 4 | import { Location } from '@angular/common' |
4 | import { isInMobileView } from '@app/shared/misc/utils' | 5 | import { isInMobileView } from '@app/shared/misc/utils' |
5 | import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive' | 6 | import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive' |
6 | import { NotificationsService } from 'angular2-notifications' | 7 | import { NotificationsService } from 'angular2-notifications' |
7 | import 'rxjs/add/operator/debounceTime' | 8 | import { fromEvent, Observable, Subscription } from 'rxjs' |
8 | import { Observable } from 'rxjs/Observable' | ||
9 | import { fromEvent } from 'rxjs/observable/fromEvent' | ||
10 | import { Subscription } from 'rxjs/Subscription' | ||
11 | import { AuthService } from '../../core/auth' | 9 | import { AuthService } from '../../core/auth' |
12 | import { ComponentPagination } from '../rest/component-pagination.model' | 10 | import { ComponentPagination } from '../rest/component-pagination.model' |
13 | import { VideoSortField } from './sort-field.type' | 11 | import { VideoSortField } from './sort-field.type' |
@@ -64,7 +62,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
64 | this.loadRouteParams(routeParams) | 62 | this.loadRouteParams(routeParams) |
65 | 63 | ||
66 | this.resizeSubscription = fromEvent(window, 'resize') | 64 | this.resizeSubscription = fromEvent(window, 'resize') |
67 | .debounceTime(500) | 65 | .pipe(debounceTime(500)) |
68 | .subscribe(() => this.calcPageSizes()) | 66 | .subscribe(() => this.calcPageSizes()) |
69 | 67 | ||
70 | this.calcPageSizes() | 68 | this.calcPageSizes() |
diff --git a/client/src/app/shared/video/infinite-scroller.directive.ts b/client/src/app/shared/video/infinite-scroller.directive.ts index e2730423f..0448e2c23 100644 --- a/client/src/app/shared/video/infinite-scroller.directive.ts +++ b/client/src/app/shared/video/infinite-scroller.directive.ts | |||
@@ -1,14 +1,6 @@ | |||
1 | import { distinct, distinctUntilChanged, filter, map, share, startWith, throttleTime } from 'rxjs/operators' | ||
1 | import { Directive, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core' | 2 | import { Directive, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core' |
2 | import 'rxjs/add/operator/debounceTime' | 3 | import { fromEvent, Subscription } from 'rxjs' |
3 | import 'rxjs/add/operator/distinct' | ||
4 | import 'rxjs/add/operator/distinctUntilChanged' | ||
5 | import 'rxjs/add/operator/filter' | ||
6 | import 'rxjs/add/operator/map' | ||
7 | import 'rxjs/add/operator/share' | ||
8 | import 'rxjs/add/operator/startWith' | ||
9 | import 'rxjs/add/operator/throttleTime' | ||
10 | import { fromEvent } from 'rxjs/observable/fromEvent' | ||
11 | import { Subscription } from 'rxjs/Subscription' | ||
12 | 4 | ||
13 | @Directive({ | 5 | @Directive({ |
14 | selector: '[myInfiniteScroller]' | 6 | selector: '[myInfiniteScroller]' |
@@ -51,43 +43,51 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy { | |||
51 | const throttleOptions = { leading: true, trailing: true } | 43 | const throttleOptions = { leading: true, trailing: true } |
52 | 44 | ||
53 | const scrollObservable = fromEvent(window, 'scroll') | 45 | const scrollObservable = fromEvent(window, 'scroll') |
54 | .startWith(true) | 46 | .pipe( |
55 | .throttleTime(200, undefined, throttleOptions) | 47 | startWith(null), |
56 | .map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight })) | 48 | throttleTime(200, undefined, throttleOptions), |
57 | .distinctUntilChanged((o1, o2) => o1.current === o2.current) | 49 | map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight })), |
58 | .share() | 50 | distinctUntilChanged((o1, o2) => o1.current === o2.current), |
51 | share() | ||
52 | ) | ||
59 | 53 | ||
60 | // Scroll Down | 54 | // Scroll Down |
61 | this.scrollDownSub = scrollObservable | 55 | this.scrollDownSub = scrollObservable |
62 | // Check we scroll down | 56 | .pipe( |
63 | .filter(({ current }) => { | 57 | // Check we scroll down |
64 | const res = this.lastCurrentBottom < current | 58 | filter(({ current }) => { |
59 | const res = this.lastCurrentBottom < current | ||
65 | 60 | ||
66 | this.lastCurrentBottom = current | 61 | this.lastCurrentBottom = current |
67 | return res | 62 | return res |
68 | }) | 63 | }), |
69 | .filter(({ current, maximumScroll }) => maximumScroll <= 0 || (current / maximumScroll) > this.decimalLimit) | 64 | filter(({ current, maximumScroll }) => maximumScroll <= 0 || (current / maximumScroll) > this.decimalLimit) |
65 | ) | ||
70 | .subscribe(() => this.nearOfBottom.emit()) | 66 | .subscribe(() => this.nearOfBottom.emit()) |
71 | 67 | ||
72 | // Scroll up | 68 | // Scroll up |
73 | this.scrollUpSub = scrollObservable | 69 | this.scrollUpSub = scrollObservable |
74 | // Check we scroll up | 70 | .pipe( |
75 | .filter(({ current }) => { | 71 | // Check we scroll up |
76 | const res = this.lastCurrentTop > current | 72 | filter(({ current }) => { |
73 | const res = this.lastCurrentTop > current | ||
77 | 74 | ||
78 | this.lastCurrentTop = current | 75 | this.lastCurrentTop = current |
79 | return res | 76 | return res |
80 | }) | 77 | }), |
81 | .filter(({ current, maximumScroll }) => { | 78 | filter(({ current, maximumScroll }) => { |
82 | return current !== 0 && (1 - (current / maximumScroll)) > this.decimalLimit | 79 | return current !== 0 && (1 - (current / maximumScroll)) > this.decimalLimit |
83 | }) | 80 | }) |
81 | ) | ||
84 | .subscribe(() => this.nearOfTop.emit()) | 82 | .subscribe(() => this.nearOfTop.emit()) |
85 | 83 | ||
86 | // Page change | 84 | // Page change |
87 | this.pageChangeSub = scrollObservable | 85 | this.pageChangeSub = scrollObservable |
88 | .distinct() | 86 | .pipe( |
89 | .map(({ current }) => this.calculateCurrentPage(current)) | 87 | distinct(), |
90 | .distinctUntilChanged() | 88 | map(({ current }) => this.calculateCurrentPage(current)), |
89 | distinctUntilChanged() | ||
90 | ) | ||
91 | .subscribe(res => this.pageChanged.emit(res)) | 91 | .subscribe(res => this.pageChanged.emit(res)) |
92 | } | 92 | } |
93 | 93 | ||
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index cd8539b41..f57cb6d6d 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
1 | import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' | 2 | import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' |
2 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
3 | import 'rxjs/add/operator/catch' | 4 | import { Observable } from 'rxjs' |
4 | import 'rxjs/add/operator/map' | ||
5 | import { Observable } from 'rxjs/Observable' | ||
6 | import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared' | 5 | import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared' |
7 | import { ResultList } from '../../../../../shared/models/result-list.model' | 6 | import { ResultList } from '../../../../../shared/models/result-list.model' |
8 | import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model' | 7 | import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model' |
@@ -43,14 +42,18 @@ export class VideoService { | |||
43 | 42 | ||
44 | getVideo (uuid: string): Observable<VideoDetails> { | 43 | getVideo (uuid: string): Observable<VideoDetails> { |
45 | return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid) | 44 | return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid) |
46 | .map(videoHash => new VideoDetails(videoHash)) | 45 | .pipe( |
47 | .catch((res) => this.restExtractor.handleError(res)) | 46 | map(videoHash => new VideoDetails(videoHash)), |
47 | catchError(res => this.restExtractor.handleError(res)) | ||
48 | ) | ||
48 | } | 49 | } |
49 | 50 | ||
50 | viewVideo (uuid: string): Observable<VideoDetails> { | 51 | viewVideo (uuid: string): Observable<VideoDetails> { |
51 | return this.authHttp.post(this.getVideoViewUrl(uuid), {}) | 52 | return this.authHttp.post(this.getVideoViewUrl(uuid), {}) |
52 | .map(this.restExtractor.extractDataBool) | 53 | .pipe( |
53 | .catch(this.restExtractor.handleError) | 54 | map(this.restExtractor.extractDataBool), |
55 | catchError(this.restExtractor.handleError) | ||
56 | ) | ||
54 | } | 57 | } |
55 | 58 | ||
56 | updateVideo (video: VideoEdit) { | 59 | updateVideo (video: VideoEdit) { |
@@ -79,16 +82,18 @@ export class VideoService { | |||
79 | const data = objectToFormData(body) | 82 | const data = objectToFormData(body) |
80 | 83 | ||
81 | return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data) | 84 | return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data) |
82 | .map(this.restExtractor.extractDataBool) | 85 | .pipe( |
83 | .catch(this.restExtractor.handleError) | 86 | map(this.restExtractor.extractDataBool), |
87 | catchError(this.restExtractor.handleError) | ||
88 | ) | ||
84 | } | 89 | } |
85 | 90 | ||
86 | uploadVideo (video: FormData) { | 91 | uploadVideo (video: FormData) { |
87 | const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) | 92 | const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) |
88 | 93 | ||
89 | return this.authHttp | 94 | return this.authHttp |
90 | .request(req) | 95 | .request(req) |
91 | .catch(this.restExtractor.handleError) | 96 | .pipe(catchError(this.restExtractor.handleError)) |
92 | } | 97 | } |
93 | 98 | ||
94 | getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> { | 99 | getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> { |
@@ -98,8 +103,10 @@ export class VideoService { | |||
98 | params = this.restService.addRestGetParams(params, pagination, sort) | 103 | params = this.restService.addRestGetParams(params, pagination, sort) |
99 | 104 | ||
100 | return this.authHttp.get(UserService.BASE_USERS_URL + '/me/videos', { params }) | 105 | return this.authHttp.get(UserService.BASE_USERS_URL + '/me/videos', { params }) |
101 | .map(this.extractVideos) | 106 | .pipe( |
102 | .catch((res) => this.restExtractor.handleError(res)) | 107 | map(this.extractVideos), |
108 | catchError(res => this.restExtractor.handleError(res)) | ||
109 | ) | ||
103 | } | 110 | } |
104 | 111 | ||
105 | getAccountVideos ( | 112 | getAccountVideos ( |
@@ -114,8 +121,10 @@ export class VideoService { | |||
114 | 121 | ||
115 | return this.authHttp | 122 | return this.authHttp |
116 | .get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params }) | 123 | .get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params }) |
117 | .map(this.extractVideos) | 124 | .pipe( |
118 | .catch((res) => this.restExtractor.handleError(res)) | 125 | map(this.extractVideos), |
126 | catchError(res => this.restExtractor.handleError(res)) | ||
127 | ) | ||
119 | } | 128 | } |
120 | 129 | ||
121 | getVideoChannelVideos ( | 130 | getVideoChannelVideos ( |
@@ -130,8 +139,10 @@ export class VideoService { | |||
130 | 139 | ||
131 | return this.authHttp | 140 | return this.authHttp |
132 | .get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid + '/videos', { params }) | 141 | .get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid + '/videos', { params }) |
133 | .map(this.extractVideos) | 142 | .pipe( |
134 | .catch((res) => this.restExtractor.handleError(res)) | 143 | map(this.extractVideos), |
144 | catchError(res => this.restExtractor.handleError(res)) | ||
145 | ) | ||
135 | } | 146 | } |
136 | 147 | ||
137 | getVideos ( | 148 | getVideos ( |
@@ -149,9 +160,11 @@ export class VideoService { | |||
149 | } | 160 | } |
150 | 161 | ||
151 | return this.authHttp | 162 | return this.authHttp |
152 | .get(VideoService.BASE_VIDEO_URL, { params }) | 163 | .get(VideoService.BASE_VIDEO_URL, { params }) |
153 | .map(this.extractVideos) | 164 | .pipe( |
154 | .catch((res) => this.restExtractor.handleError(res)) | 165 | map(this.extractVideos), |
166 | catchError(res => this.restExtractor.handleError(res)) | ||
167 | ) | ||
155 | } | 168 | } |
156 | 169 | ||
157 | buildBaseFeedUrls (params: HttpParams) { | 170 | buildBaseFeedUrls (params: HttpParams) { |
@@ -215,23 +228,29 @@ export class VideoService { | |||
215 | params = params.append('search', search) | 228 | params = params.append('search', search) |
216 | 229 | ||
217 | return this.authHttp | 230 | return this.authHttp |
218 | .get<ResultList<VideoServerModel>>(url, { params }) | 231 | .get<ResultList<VideoServerModel>>(url, { params }) |
219 | .map(this.extractVideos) | 232 | .pipe( |
220 | .catch((res) => this.restExtractor.handleError(res)) | 233 | map(this.extractVideos), |
234 | catchError(res => this.restExtractor.handleError(res)) | ||
235 | ) | ||
221 | } | 236 | } |
222 | 237 | ||
223 | removeVideo (id: number) { | 238 | removeVideo (id: number) { |
224 | return this.authHttp | 239 | return this.authHttp |
225 | .delete(VideoService.BASE_VIDEO_URL + id) | 240 | .delete(VideoService.BASE_VIDEO_URL + id) |
226 | .map(this.restExtractor.extractDataBool) | 241 | .pipe( |
227 | .catch((res) => this.restExtractor.handleError(res)) | 242 | map(this.restExtractor.extractDataBool), |
243 | catchError(res => this.restExtractor.handleError(res)) | ||
244 | ) | ||
228 | } | 245 | } |
229 | 246 | ||
230 | loadCompleteDescription (descriptionPath: string) { | 247 | loadCompleteDescription (descriptionPath: string) { |
231 | return this.authHttp | 248 | return this.authHttp |
232 | .get(environment.apiUrl + descriptionPath) | 249 | .get(environment.apiUrl + descriptionPath) |
233 | .map(res => res['description']) | 250 | .pipe( |
234 | .catch((res) => this.restExtractor.handleError(res)) | 251 | map(res => res[ 'description' ]), |
252 | catchError(res => this.restExtractor.handleError(res)) | ||
253 | ) | ||
235 | } | 254 | } |
236 | 255 | ||
237 | setVideoLike (id: number) { | 256 | setVideoLike (id: number) { |
@@ -250,8 +269,8 @@ export class VideoService { | |||
250 | const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' | 269 | const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' |
251 | 270 | ||
252 | return this.authHttp | 271 | return this.authHttp |
253 | .get(url) | 272 | .get(url) |
254 | .catch(res => this.restExtractor.handleError(res)) | 273 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
255 | } | 274 | } |
256 | 275 | ||
257 | private setVideoRate (id: number, rateType: VideoRateType) { | 276 | private setVideoRate (id: number, rateType: VideoRateType) { |
@@ -261,9 +280,11 @@ export class VideoService { | |||
261 | } | 280 | } |
262 | 281 | ||
263 | return this.authHttp | 282 | return this.authHttp |
264 | .put(url, body) | 283 | .put(url, body) |
265 | .map(this.restExtractor.extractDataBool) | 284 | .pipe( |
266 | .catch(res => this.restExtractor.handleError(res)) | 285 | map(this.restExtractor.extractDataBool), |
286 | catchError(res => this.restExtractor.handleError(res)) | ||
287 | ) | ||
267 | } | 288 | } |
268 | 289 | ||
269 | private extractVideos (result: ResultList<VideoServerModel>) { | 290 | private extractVideos (result: ResultList<VideoServerModel>) { |