1 import { forkJoin, 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 {
19 loadUserVideoPreferences = true
22 filter: VideoFilter = null
24 private account: Account
25 private accountSub: Subscription
28 protected router: Router,
29 protected serverService: ServerService,
30 protected route: ActivatedRoute,
31 protected authService: AuthService,
32 protected userService: UserService,
33 protected notifier: Notifier,
34 protected confirmService: ConfirmService,
35 protected screenService: ScreenService,
36 protected storageService: LocalStorageService,
37 protected cfr: ComponentFactoryResolver,
38 private accountService: AccountService,
39 private videoService: VideoService
47 this.enableAllFilterIfPossible()
49 // Parent get the account for us
50 this.accountSub = forkJoin([
51 this.accountService.accountLoaded.pipe(first()),
52 this.onUserLoadedSubject.pipe(first())
53 ]).subscribe(([ account ]) => {
54 this.account = account
61 if (this.accountSub) this.accountSub.unsubscribe()
66 updateSearch (value: string) {
70 this.router.navigate([ '../videos' ], { relativeTo: this.route })
78 getVideosObservable (page: number) {
79 const newPagination = immutableAssign(this.pagination, { currentPage: page })
81 account: this.account,
82 videoPagination: newPagination,
84 nsfwPolicy: this.nsfwPolicy,
85 videoFilter: this.filter,
89 return this.videoService
90 .getAccountVideos(options)
93 this.titlePage = this.search
94 ? $localize`Published ${total} videos matching "${this.search}"`
95 : $localize`Published ${total} videos`
100 toggleModerationDisplay () {
101 this.filter = this.buildLocalFilter(this.filter, null)
106 generateSyndicationList () {
107 /* method disabled */
108 throw new Error('Method not implemented.')