aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/video/video.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/video/video.service.ts')
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts21
1 files changed, 19 insertions, 2 deletions
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 bc15c326f..142367506 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -3,7 +3,7 @@ import { from, Observable } from 'rxjs'
3import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' 3import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
4import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' 4import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core' 6import { AuthService, ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core'
7import { objectToFormData } from '@app/helpers' 7import { objectToFormData } from '@app/helpers'
8import { 8import {
9 BooleanBothQuery, 9 BooleanBothQuery,
@@ -55,6 +55,7 @@ export class VideoService {
55 static BASE_SUBSCRIPTION_FEEDS_URL = environment.apiUrl + '/feeds/subscriptions.' 55 static BASE_SUBSCRIPTION_FEEDS_URL = environment.apiUrl + '/feeds/subscriptions.'
56 56
57 constructor ( 57 constructor (
58 private auth: AuthService,
58 private authHttp: HttpClient, 59 private authHttp: HttpClient,
59 private restExtractor: RestExtractor, 60 private restExtractor: RestExtractor,
60 private restService: RestService, 61 private restService: RestService,
@@ -418,7 +419,7 @@ export class VideoService {
418 ? this.restService.componentToRestPagination(videoPagination) 419 ? this.restService.componentToRestPagination(videoPagination)
419 : undefined 420 : undefined
420 421
421 let newParams = this.restService.addRestGetParams(params, pagination, sort) 422 let newParams = this.restService.addRestGetParams(params, pagination, this.buildListSort(sort))
422 423
423 if (skipCount) newParams = newParams.set('skipCount', skipCount + '') 424 if (skipCount) newParams = newParams.set('skipCount', skipCount + '')
424 425
@@ -434,6 +435,22 @@ export class VideoService {
434 return newParams 435 return newParams
435 } 436 }
436 437
438 private buildListSort (sortArg: VideoSortField | SortMeta) {
439 const sort = this.restService.buildSortString(sortArg)
440
441 if (typeof sort === 'string') {
442 // Silently use the best algorithm for logged in users if they chose the hot algorithm
443 if (
444 this.auth.isLoggedIn() &&
445 (sort === 'hot' || sort === '-hot')
446 ) {
447 return sort.replace('hot', 'best')
448 }
449
450 return sort
451 }
452 }
453
437 private setVideoRate (id: number, rateType: UserVideoRateType) { 454 private setVideoRate (id: number, rateType: UserVideoRateType) {
438 const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate` 455 const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
439 const body: UserVideoRateUpdate = { 456 const body: UserVideoRateUpdate = {