1 import { Subscription } from 'rxjs'
2 import { first, tap } from 'rxjs/operators'
3 import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
4 import { ActivatedRoute, Router } from '@angular/router'
5 import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
6 import { immutableAssign } from '@app/helpers'
7 import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
9 import { VideoFilter } from '@shared/models'
12 selector: 'my-account-search',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
14 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ]
16 export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
21 filter: VideoFilter = null
23 private account: Account
24 private accountSub: Subscription
27 protected router: Router,
28 protected serverService: ServerService,
29 protected route: ActivatedRoute,
30 protected authService: AuthService,
31 protected userService: UserService,
32 protected notifier: Notifier,
33 protected confirmService: ConfirmService,
34 protected screenService: ScreenService,
35 protected storageService: LocalStorageService,
36 protected cfr: ComponentFactoryResolver,
37 private accountService: AccountService,
38 private videoService: VideoService
46 this.enableAllFilterIfPossible()
48 // Parent get the account for us
49 this.accountSub = this.accountService.accountLoaded
51 .subscribe(account => {
52 this.account = account
55 this.generateSyndicationList()
60 if (this.accountSub) this.accountSub.unsubscribe()
65 updateSearch (value: string) {
66 if (value === '') this.router.navigate(['../videos'], { relativeTo: this.route })
72 getVideosObservable (page: number) {
73 const newPagination = immutableAssign(this.pagination, { currentPage: page })
75 account: this.account,
76 videoPagination: newPagination,
78 nsfwPolicy: this.nsfwPolicy,
79 videoFilter: this.filter,
83 return this.videoService
84 .getAccountVideos(options)
87 this.titlePage = this.search
88 ? $localize`Published ${total} videos matching "${this.search}"`
89 : $localize`Published ${total} videos`
94 toggleModerationDisplay () {
95 this.filter = this.buildLocalFilter(this.filter, null)
100 generateSyndicationList () {
101 /* method disabled */
102 throw new Error('Method not implemented.')