aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html1
-rw-r--r--client/src/app/+videos/video-list/videos-list-common-page.component.ts3
-rw-r--r--client/src/app/core/rest/rest.service.ts18
-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
6 files changed, 31 insertions, 22 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html
index 3673a805b..bae9d9775 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html
@@ -44,7 +44,6 @@
44 44
45 <div class="peertube-select-container"> 45 <div class="peertube-select-container">
46 <select id="trendingVideosAlgorithmsDefault" formControlName="default" class="form-control"> 46 <select id="trendingVideosAlgorithmsDefault" formControlName="default" class="form-control">
47 <option i18n value="best">Best videos</option>
48 <option i18n value="hot">Hot videos</option> 47 <option i18n value="hot">Hot videos</option>
49 <option i18n value="most-viewed">Most viewed videos</option> 48 <option i18n value="most-viewed">Most viewed videos</option>
50 <option i18n value="most-liked">Most liked videos</option> 49 <option i18n value="most-liked">Most liked videos</option>
diff --git a/client/src/app/+videos/video-list/videos-list-common-page.component.ts b/client/src/app/+videos/video-list/videos-list-common-page.component.ts
index d03b09610..32737ef1c 100644
--- a/client/src/app/+videos/video-list/videos-list-common-page.component.ts
+++ b/client/src/app/+videos/video-list/videos-list-common-page.component.ts
@@ -197,10 +197,9 @@ export class VideosListCommonPageComponent implements OnInit, OnDestroy, Disable
197 return 197 return
198 } 198 }
199 199
200 if ([ 'best', 'hot', 'trending', 'likes' ].includes(sanitizedSort)) { 200 if ([ 'hot', 'trending', 'likes' ].includes(sanitizedSort)) {
201 this.title = $localize`Trending` 201 this.title = $localize`Trending`
202 202
203 if (sanitizedSort === 'best') this.titleTooltip = $localize`Videos with the most interactions for recent videos, minus user history`
204 if (sanitizedSort === 'hot') this.titleTooltip = $localize`Videos with the most interactions for recent videos` 203 if (sanitizedSort === 'hot') this.titleTooltip = $localize`Videos with the most interactions for recent videos`
205 if (sanitizedSort === 'likes') this.titleTooltip = $localize`Videos that have the most likes` 204 if (sanitizedSort === 'likes') this.titleTooltip = $localize`Videos that have the most likes`
206 205
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts
index b2a5a3f72..fc729f0f6 100644
--- a/client/src/app/core/rest/rest.service.ts
+++ b/client/src/app/core/rest/rest.service.ts
@@ -31,19 +31,19 @@ export class RestService {
31 } 31 }
32 32
33 if (sort !== undefined) { 33 if (sort !== undefined) {
34 let sortString = '' 34 newParams = newParams.set('sort', this.buildSortString(sort))
35 }
35 36
36 if (typeof sort === 'string') { 37 return newParams
37 sortString = sort 38 }
38 } else {
39 const sortPrefix = sort.order === 1 ? '' : '-'
40 sortString = sortPrefix + sort.field
41 }
42 39
43 newParams = newParams.set('sort', sortString) 40 buildSortString (sort: SortMeta | string) {
41 if (typeof sort === 'string') {
42 return sort
44 } 43 }
45 44
46 return newParams 45 const sortPrefix = sort.order === 1 ? '' : '-'
46 return sortPrefix + sort.field
47 } 47 }
48 48
49 addArrayParams (params: HttpParams, name: string, values: (string | number)[]) { 49 addArrayParams (params: HttpParams, name: string, values: (string | number)[]) {
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) {