aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-list
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-13 14:11:05 +0100
committerChocobozzz <me@florianbigard.com>2018-02-13 14:20:46 +0100
commit0cd4344f3cf529b15308fcf3eb7d7eb07726df56 (patch)
tree276f6e8cfe72d583114d82fd5db981550a395488 /client/src/app/videos/video-list
parent29c6b829446a6fb29dffc6b7b638079ce60f3771 (diff)
downloadPeerTube-0cd4344f3cf529b15308fcf3eb7d7eb07726df56.tar.gz
PeerTube-0cd4344f3cf529b15308fcf3eb7d7eb07726df56.tar.zst
PeerTube-0cd4344f3cf529b15308fcf3eb7d7eb07726df56.zip
Rewrite infinite scroll
Diffstat (limited to 'client/src/app/videos/video-list')
-rw-r--r--client/src/app/videos/video-list/video-recently-added.component.ts7
-rw-r--r--client/src/app/videos/video-list/video-search.component.ts12
-rw-r--r--client/src/app/videos/video-list/video-trending.component.ts6
3 files changed, 16 insertions, 9 deletions
diff --git a/client/src/app/videos/video-list/video-recently-added.component.ts b/client/src/app/videos/video-list/video-recently-added.component.ts
index 3020b8c30..f150e38da 100644
--- a/client/src/app/videos/video-list/video-recently-added.component.ts
+++ b/client/src/app/videos/video-list/video-recently-added.component.ts
@@ -1,5 +1,6 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
3import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
4import { AuthService } from '../../core/auth' 5import { AuthService } from '../../core/auth'
5import { AbstractVideoList } from '../../shared/video/abstract-video-list' 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
@@ -28,7 +29,9 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
28 super.ngOnInit() 29 super.ngOnInit()
29 } 30 }
30 31
31 getVideosObservable () { 32 getVideosObservable (page: number) {
32 return this.videoService.getVideos(this.pagination, this.sort) 33 const newPagination = immutableAssign(this.pagination, { currentPage: page })
34
35 return this.videoService.getVideos(newPagination, this.sort)
33 } 36 }
34} 37}
diff --git a/client/src/app/videos/video-list/video-search.component.ts b/client/src/app/videos/video-list/video-search.component.ts
index 67726afdc..241b97bc7 100644
--- a/client/src/app/videos/video-list/video-search.component.ts
+++ b/client/src/app/videos/video-list/video-search.component.ts
@@ -1,5 +1,6 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
3import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
4import { Subscription } from 'rxjs/Subscription' 5import { Subscription } from 'rxjs/Subscription'
5import { AuthService } from '../../core/auth' 6import { AuthService } from '../../core/auth'
@@ -16,7 +17,7 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
16 currentRoute = '/videos/search' 17 currentRoute = '/videos/search'
17 loadOnInit = false 18 loadOnInit = false
18 19
19 protected otherParams = { 20 protected otherRouteParams = {
20 search: '' 21 search: ''
21 } 22 }
22 private subActivatedRoute: Subscription 23 private subActivatedRoute: Subscription
@@ -35,9 +36,9 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
35 this.subActivatedRoute = this.route.queryParams.subscribe( 36 this.subActivatedRoute = this.route.queryParams.subscribe(
36 queryParams => { 37 queryParams => {
37 const querySearch = queryParams['search'] 38 const querySearch = queryParams['search']
38 if (!querySearch || this.otherParams.search === querySearch) return 39 if (!querySearch || this.otherRouteParams.search === querySearch) return
39 40
40 this.otherParams.search = querySearch 41 this.otherRouteParams.search = querySearch
41 this.reloadVideos() 42 this.reloadVideos()
42 }, 43 },
43 44
@@ -51,7 +52,8 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
51 } 52 }
52 } 53 }
53 54
54 getVideosObservable () { 55 getVideosObservable (page: number) {
55 return this.videoService.searchVideos(this.otherParams.search, this.pagination, this.sort) 56 const newPagination = immutableAssign(this.pagination, { currentPage: page })
57 return this.videoService.searchVideos(this.otherRouteParams.search, newPagination, this.sort)
56 } 58 }
57} 59}
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 fc48086d6..a42457273 100644
--- a/client/src/app/videos/video-list/video-trending.component.ts
+++ b/client/src/app/videos/video-list/video-trending.component.ts
@@ -1,5 +1,6 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
3import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
4import { AuthService } from '../../core/auth' 5import { AuthService } from '../../core/auth'
5import { AbstractVideoList } from '../../shared/video/abstract-video-list' 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
@@ -28,7 +29,8 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit
28 super.ngOnInit() 29 super.ngOnInit()
29 } 30 }
30 31
31 getVideosObservable () { 32 getVideosObservable (page: number) {
32 return this.videoService.getVideos(this.pagination, this.sort) 33 const newPagination = immutableAssign(this.pagination, { currentPage: page })
34 return this.videoService.getVideos(newPagination, this.sort)
33 } 35 }
34} 36}