diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-13 14:11:05 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-13 14:20:46 +0100 |
commit | 0cd4344f3cf529b15308fcf3eb7d7eb07726df56 (patch) | |
tree | 276f6e8cfe72d583114d82fd5db981550a395488 /client/src/app/videos/video-list/video-search.component.ts | |
parent | 29c6b829446a6fb29dffc6b7b638079ce60f3771 (diff) | |
download | PeerTube-0cd4344f3cf529b15308fcf3eb7d7eb07726df56.tar.gz PeerTube-0cd4344f3cf529b15308fcf3eb7d7eb07726df56.tar.zst PeerTube-0cd4344f3cf529b15308fcf3eb7d7eb07726df56.zip |
Rewrite infinite scroll
Diffstat (limited to 'client/src/app/videos/video-list/video-search.component.ts')
-rw-r--r-- | client/src/app/videos/video-list/video-search.component.ts | 12 |
1 files changed, 7 insertions, 5 deletions
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 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { immutableAssign } from '@app/shared/misc/utils' | ||
3 | import { NotificationsService } from 'angular2-notifications' | 4 | import { NotificationsService } from 'angular2-notifications' |
4 | import { Subscription } from 'rxjs/Subscription' | 5 | import { Subscription } from 'rxjs/Subscription' |
5 | import { AuthService } from '../../core/auth' | 6 | import { 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 | } |