X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2Fvideo-list%2Fvideo-trending.component.ts;h=0e69bfd645e23cc0fd981717f246f305ea8f1679;hb=93cae47925e4dd68b7d34a41927b2740b4fab1b4;hp=881ab2174d2f9031bc2f573b08381b0ee795f353;hpb=7b95f31385eca59ac18197539de30268acc18986;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/video-list/video-trending.component.ts b/client/src/app/videos/video-list/video-trending.component.ts index 881ab2174..0e69bfd64 100644 --- a/client/src/app/videos/video-list/video-trending.component.ts +++ b/client/src/app/videos/video-list/video-trending.component.ts @@ -1,6 +1,5 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' -import { Location } from '@angular/common' import { immutableAssign } from '@app/shared/misc/utils' import { AuthService } from '../../core/auth' import { AbstractVideoList } from '../../shared/video/abstract-video-list' @@ -9,6 +8,7 @@ import { VideoService } from '../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { ScreenService } from '@app/shared/misc/screen.service' import { Notifier, ServerService } from '@app/core' +import { HooksService } from '@app/core/plugins/hooks.service' @Component({ selector: 'my-videos-trending', @@ -17,19 +17,20 @@ import { Notifier, ServerService } from '@app/core' }) export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { titlePage: string - currentRoute = '/videos/trending' defaultSort: VideoSortField = '-trending' + useUserVideoLanguagePreferences = true + constructor ( + protected i18n: I18n, protected router: Router, + protected serverService: ServerService, protected route: ActivatedRoute, protected notifier: Notifier, protected authService: AuthService, - protected location: Location, protected screenService: ScreenService, - private serverService: ServerService, - protected i18n: I18n, - private videoService: VideoService + private videoService: VideoService, + private hooks: HooksService ) { super() } @@ -39,18 +40,21 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, this.generateSyndicationList() - const trendingDays = this.serverService.getConfig().trending.videos.intervalDays + this.serverService.configLoaded.subscribe( + () => { + const trendingDays = this.serverService.getConfig().trending.videos.intervalDays - if (trendingDays === 1) { - this.titlePage = this.i18n('Trending for the last 24 hours') - this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours.') - } else { - this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays }) - this.titleTooltip = this.i18n( - 'Trending videos are those totalizing the greatest number of views during the last {{days}} days.', - { days: trendingDays } - ) - } + if (trendingDays === 1) { + this.titlePage = this.i18n('Trending for the last 24 hours') + this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours') + } else { + this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays }) + this.titleTooltip = this.i18n( + 'Trending videos are those totalizing the greatest number of views during the last {{days}} days', + { days: trendingDays } + ) + } + }) } ngOnDestroy () { @@ -59,7 +63,20 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, getVideosObservable (page: number) { const newPagination = immutableAssign(this.pagination, { currentPage: page }) - return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf) + const params = { + videoPagination: newPagination, + sort: this.sort, + categoryOneOf: this.categoryOneOf, + languageOneOf: this.languageOneOf + } + + return this.hooks.wrapObsFun( + this.videoService.getVideos.bind(this.videoService), + params, + 'common', + 'filter:api.videos.list.trending.params', + 'filter:api.videos.list.trending.result' + ) } generateSyndicationList () {