]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-search.component.ts
Add infinite scroll to comments
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-search.component.ts
CommitLineData
f3aaa9a9
C
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications'
f3aaa9a9 4import { Subscription } from 'rxjs/Subscription'
b2731bff 5import { AuthService } from '../../core/auth'
7bfd1b1e 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
f3aaa9a9
C
7import { VideoService } from '../../shared/video/video.service'
8
9@Component({
10 selector: 'my-videos-search',
11 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
12 templateUrl: '../../shared/video/abstract-video-list.html'
13})
14export class VideoSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
15 titlePage = 'Search'
16 currentRoute = '/videos/search'
17 loadOnInit = false
18
19 private search = ''
20 private subActivatedRoute: Subscription
21
22 constructor (protected router: Router,
23 protected route: ActivatedRoute,
24 protected notificationsService: NotificationsService,
b2731bff 25 protected authService: AuthService,
f3aaa9a9
C
26 private videoService: VideoService) {
27 super()
28 }
29
30 ngOnInit () {
31 super.ngOnInit()
32
33 this.subActivatedRoute = this.route.queryParams.subscribe(
34 queryParams => {
35 this.search = queryParams['search']
36 this.reloadVideos()
37 },
38
39 err => this.notificationsService.error('Error', err.text)
40 )
41 }
42
43 ngOnDestroy () {
44 if (this.subActivatedRoute) {
45 this.subActivatedRoute.unsubscribe()
46 }
47 }
48
49 getVideosObservable () {
50 return this.videoService.searchVideos(this.search, this.pagination, this.sort)
51 }
52}