From aea0b0e7cde7495e60fe07b4444067f53d35ce3f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 14 May 2021 12:04:44 +0200 Subject: Inject server config in HTML --- .../video-list/trending/video-trending-header.component.ts | 12 ++++-------- .../+videos/video-list/trending/video-trending.component.ts | 7 +++++-- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'client/src/app/+videos/video-list') diff --git a/client/src/app/+videos/video-list/trending/video-trending-header.component.ts b/client/src/app/+videos/video-list/trending/video-trending-header.component.ts index 55040f3c9..bbb02a236 100644 --- a/client/src/app/+videos/video-list/trending/video-trending-header.component.ts +++ b/client/src/app/+videos/video-list/trending/video-trending-header.component.ts @@ -31,7 +31,8 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent imple private route: ActivatedRoute, private router: Router, private auth: AuthService, - private serverService: ServerService + private serverService: ServerService, + private redirectService: RedirectService ) { super(data) @@ -84,12 +85,7 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent imple this.algorithmChangeSub = this.route.queryParams.subscribe( queryParams => { - const algorithm = queryParams['alg'] - if (algorithm) { - this.data.model = algorithm - } else { - this.data.model = RedirectService.DEFAULT_TRENDING_ALGORITHM - } + this.data.model = queryParams['alg'] || this.redirectService.getDefaultTrendingAlgorithm() } ) } @@ -99,7 +95,7 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent imple } setSort () { - const alg = this.data.model !== RedirectService.DEFAULT_TRENDING_ALGORITHM + const alg = this.data.model !== this.redirectService.getDefaultTrendingAlgorithm() ? this.data.model : undefined diff --git a/client/src/app/+videos/video-list/trending/video-trending.component.ts b/client/src/app/+videos/video-list/trending/video-trending.component.ts index e50d6ec3a..ebec672f3 100644 --- a/client/src/app/+videos/video-list/trending/video-trending.component.ts +++ b/client/src/app/+videos/video-list/trending/video-trending.component.ts @@ -35,11 +35,12 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, protected storageService: LocalStorageService, protected cfr: ComponentFactoryResolver, private videoService: VideoService, + private redirectService: RedirectService, private hooks: HooksService ) { super() - this.defaultSort = this.parseAlgorithm(RedirectService.DEFAULT_TRENDING_ALGORITHM) + this.defaultSort = this.parseAlgorithm(this.redirectService.getDefaultTrendingAlgorithm()) this.headerComponentInjector = this.getInjector() } @@ -106,7 +107,7 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, } protected loadPageRouteParams (queryParams: Params) { - const algorithm = queryParams['alg'] || RedirectService.DEFAULT_TRENDING_ALGORITHM + const algorithm = queryParams['alg'] || this.redirectService.getDefaultTrendingAlgorithm() this.sort = this.parseAlgorithm(algorithm) } @@ -115,8 +116,10 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, switch (algorithm) { case 'most-viewed': return '-trending' + case 'most-liked': return '-likes' + default: return '-' + algorithm as VideoSortField } -- cgit v1.2.3