X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-main%2Fvideo%2Fvideo.service.ts;h=4fbc4f7f62ae3389177a9cd0f11c9459bf3770a8;hb=a2fb5fb8b1007e3ce82e707917f5d9a37374e99b;hp=9efa1a24eb29d3af3d86646c673b4a199f31fb71;hpb=5079082d0d94b9e91e8bb75f877d93e54e77b647;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 9efa1a24e..4fbc4f7f6 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -1,5 +1,5 @@ import { SortMeta } from 'primeng/api' -import { from, Observable } from 'rxjs' +import { from, Observable, of } from 'rxjs' import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' import { Injectable } from '@angular/core' @@ -24,6 +24,7 @@ import { VideoTranscodingCreate, VideoUpdate } from '@shared/models' +import { VideoSource } from '@shared/models/videos/video-source' import { environment } from '../../../../environments/environment' import { Account } from '../account/account.model' import { AccountService } from '../account/account.service' @@ -323,19 +324,33 @@ export class VideoService { ) } - setVideoLike (id: number) { + getSource (videoId: number) { + return this.authHttp + .get<{ source: VideoSource }>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/source') + .pipe( + catchError(err => { + if (err.status === 404) { + return of(undefined) + } + + this.restExtractor.handleError(err) + }) + ) + } + + setVideoLike (id: string) { return this.setVideoRate(id, 'like') } - setVideoDislike (id: number) { + setVideoDislike (id: string) { return this.setVideoRate(id, 'dislike') } - unsetVideoLike (id: number) { + unsetVideoLike (id: string) { return this.setVideoRate(id, 'none') } - getUserVideoRating (id: number) { + getUserVideoRating (id: string) { const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' return this.authHttp.get(url) @@ -451,7 +466,7 @@ export class VideoService { } } - private setVideoRate (id: number, rateType: UserVideoRateType) { + private setVideoRate (id: string, rateType: UserVideoRateType) { const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate` const body: UserVideoRateUpdate = { rating: rateType