aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts21
-rw-r--r--client/src/app/shared/shared-video-miniature/video-filters-header.component.html1
-rw-r--r--client/src/app/shared/shared-video-miniature/video-filters-header.component.ts9
3 files changed, 21 insertions, 10 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 = {
diff --git a/client/src/app/shared/shared-video-miniature/video-filters-header.component.html b/client/src/app/shared/shared-video-miniature/video-filters-header.component.html
index 7f5692dd4..fc34b1b29 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters-header.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-filters-header.component.html
@@ -47,7 +47,6 @@
47 47
48 <ng-option i18n *ngIf="isTrendingSortEnabled('most-viewed')" value="-trending">Sort by <strong>"Recent Views"</strong></ng-option> 48 <ng-option i18n *ngIf="isTrendingSortEnabled('most-viewed')" value="-trending">Sort by <strong>"Recent Views"</strong></ng-option>
49 <ng-option i18n *ngIf="isTrendingSortEnabled('hot')" value="-hot">Sort by <strong>"Hot"</strong></ng-option> 49 <ng-option i18n *ngIf="isTrendingSortEnabled('hot')" value="-hot">Sort by <strong>"Hot"</strong></ng-option>
50 <ng-option i18n *ngIf="isTrendingSortEnabled('best')" value="-best">Sort by <strong>"Best"</strong></ng-option>
51 <ng-option i18n *ngIf="isTrendingSortEnabled('most-liked')" value="-likes">Sort by <strong>"Likes"</strong></ng-option> 50 <ng-option i18n *ngIf="isTrendingSortEnabled('most-liked')" value="-likes">Sort by <strong>"Likes"</strong></ng-option>
52 </ng-select> 51 </ng-select>
53 52
diff --git a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
index 2c52e43f7..7b806248b 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
@@ -72,15 +72,10 @@ export class VideoFiltersHeaderComponent implements OnInit, OnDestroy {
72 return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS) 72 return this.auth.getUser().hasRight(UserRight.SEE_ALL_VIDEOS)
73 } 73 }
74 74
75 isTrendingSortEnabled (sort: 'most-viewed' | 'hot' | 'best' | 'most-liked') { 75 isTrendingSortEnabled (sort: 'most-viewed' | 'hot' | 'most-liked') {
76 const serverConfig = this.serverService.getHTMLConfig() 76 const serverConfig = this.serverService.getHTMLConfig()
77 77
78 const enabled = serverConfig.trending.videos.algorithms.enabled.includes(sort) 78 return serverConfig.trending.videos.algorithms.enabled.includes(sort)
79
80 // Best is adapted from the user
81 if (sort === 'best') return enabled && this.auth.isLoggedIn()
82
83 return enabled
84 } 79 }
85 80
86 resetFilter (key: string, canRemove: boolean) { 81 resetFilter (key: string, canRemove: boolean) {