]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-search.component.ts
Fix deleting a video with 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
c88593f7
C
19 protected otherParams = {
20 search: ''
21 }
f3aaa9a9
C
22 private subActivatedRoute: Subscription
23
24 constructor (protected router: Router,
25 protected route: ActivatedRoute,
26 protected notificationsService: NotificationsService,
b2731bff 27 protected authService: AuthService,
f3aaa9a9
C
28 private videoService: VideoService) {
29 super()
30 }
31
32 ngOnInit () {
33 super.ngOnInit()
34
35 this.subActivatedRoute = this.route.queryParams.subscribe(
36 queryParams => {
c88593f7
C
37 const querySearch = queryParams['search']
38 if (!querySearch || this.otherParams.search === querySearch) return
39
40 this.otherParams.search = querySearch
f3aaa9a9
C
41 this.reloadVideos()
42 },
43
44 err => this.notificationsService.error('Error', err.text)
45 )
46 }
47
48 ngOnDestroy () {
49 if (this.subActivatedRoute) {
50 this.subActivatedRoute.unsubscribe()
51 }
52 }
53
54 getVideosObservable () {
c88593f7 55 return this.videoService.searchVideos(this.otherParams.search, this.pagination, this.sort)
f3aaa9a9
C
56 }
57}