aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+videos/video-list/trending/video-trending.component.ts27
-rw-r--r--client/src/app/shared/shared-video-miniature/abstract-video-list.ts18
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts2
3 files changed, 35 insertions, 12 deletions
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 c11f0da9d..e50d6ec3a 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
@@ -1,12 +1,13 @@
1import { Subscription } from 'rxjs'
2import { first, switchMap } from 'rxjs/operators'
1import { Component, ComponentFactoryResolver, Injector, OnDestroy, OnInit } from '@angular/core' 3import { Component, ComponentFactoryResolver, Injector, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Params, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, RedirectService, ScreenService, ServerService, UserService } from '@app/core' 5import { AuthService, LocalStorageService, Notifier, RedirectService, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service' 6import { HooksService } from '@app/core/plugins/hooks.service'
5import { immutableAssign } from '@app/helpers' 7import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main' 8import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature' 9import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8import { VideoSortField } from '@shared/models' 10import { VideoSortField } from '@shared/models'
9import { Subscription } from 'rxjs'
10import { VideoTrendingHeaderComponent } from './video-trending-header.component' 11import { VideoTrendingHeaderComponent } from './video-trending-header.component'
11 12
12@Component({ 13@Component({
@@ -48,12 +49,18 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
48 49
49 this.generateSyndicationList() 50 this.generateSyndicationList()
50 51
51 this.algorithmChangeSub = this.route.queryParams.subscribe( 52 // Subscribe to alg change after we loaded the data
52 queryParams => { 53 // The initial alg load is handled by the parent class
53 const algorithm = queryParams['alg'] || RedirectService.DEFAULT_TRENDING_ALGORITHM 54 this.algorithmChangeSub = this.onDataSubject
55 .pipe(
56 first(),
57 switchMap(() => this.route.queryParams)
58 ).subscribe(queryParams => {
59 const oldSort = this.sort
60
61 this.loadPageRouteParams(queryParams)
54 62
55 this.sort = this.parseAlgorithm(algorithm) 63 if (oldSort !== this.sort) this.reloadVideos()
56 this.reloadVideos()
57 } 64 }
58 ) 65 )
59 } 66 }
@@ -98,6 +105,12 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
98 }) 105 })
99 } 106 }
100 107
108 protected loadPageRouteParams (queryParams: Params) {
109 const algorithm = queryParams['alg'] || RedirectService.DEFAULT_TRENDING_ALGORITHM
110
111 this.sort = this.parseAlgorithm(algorithm)
112 }
113
101 private parseAlgorithm (algorithm: string): VideoSortField { 114 private parseAlgorithm (algorithm: string): VideoSortField {
102 switch (algorithm) { 115 switch (algorithm) {
103 case 'most-viewed': 116 case 'most-viewed':
diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
index f8abc1656..c13cb3748 100644
--- a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
+++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
@@ -11,7 +11,7 @@ import {
11 ViewChild, 11 ViewChild,
12 ViewContainerRef 12 ViewContainerRef
13} from '@angular/core' 13} from '@angular/core'
14import { ActivatedRoute, Router } from '@angular/router' 14import { ActivatedRoute, Params, Router } from '@angular/router'
15import { 15import {
16 AuthService, 16 AuthService,
17 ComponentPaginationLight, 17 ComponentPaginationLight,
@@ -199,6 +199,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
199 // No more results 199 // No more results
200 if (this.lastQueryLength !== undefined && this.lastQueryLength < this.pagination.itemsPerPage) return 200 if (this.lastQueryLength !== undefined && this.lastQueryLength < this.pagination.itemsPerPage) return
201 201
202 console.log('near of bottom')
202 this.pagination.currentPage += 1 203 this.pagination.currentPage += 1
203 204
204 this.setScrollRouteParams() 205 this.setScrollRouteParams()
@@ -322,10 +323,17 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
322 // On videos hook for children that want to do something 323 // On videos hook for children that want to do something
323 protected onMoreVideos () { /* empty */ } 324 protected onMoreVideos () { /* empty */ }
324 325
325 protected loadRouteParams (routeParams: { [ key: string ]: any }) { 326 protected load () { /* empty */ }
326 this.sort = routeParams[ 'sort' ] as VideoSortField || this.defaultSort 327
327 this.categoryOneOf = routeParams[ 'categoryOneOf' ] 328 // Hook if the page has custom route params
328 this.angularState = routeParams[ 'a-state' ] 329 protected loadPageRouteParams (_queryParams: Params) { /* empty */ }
330
331 protected loadRouteParams (queryParams: Params) {
332 this.sort = queryParams[ 'sort' ] as VideoSortField || this.defaultSort
333 this.categoryOneOf = queryParams[ 'categoryOneOf' ]
334 this.angularState = queryParams[ 'a-state' ]
335
336 this.loadPageRouteParams(queryParams)
329 } 337 }
330 338
331 protected buildLocalFilter (existing: VideoFilter, base: VideoFilter) { 339 protected buildLocalFilter (existing: VideoFilter, base: VideoFilter) {
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index cff19223f..4c00d97f8 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -121,6 +121,8 @@ describe('Test moderation notifications', function () {
121 const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) 121 const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4())
122 const comment = resComment.body.comment 122 const comment = resComment.body.comment
123 123
124 await waitJobs(servers)
125
124 await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, commentId: comment.id, reason: 'super reason' }) 126 await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, commentId: comment.id, reason: 'super reason' })
125 127
126 await waitJobs(servers) 128 await waitJobs(servers)