1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { immutableAssign } from '@app/shared/misc/utils'
4 import { AuthService } from '../../core/auth'
5 import { ConfirmService } from '../../core/confirm'
6 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7 import { VideoService } from '../../shared/video/video.service'
8 import { Account } from '@app/shared/account/account.model'
9 import { AccountService } from '@app/shared/account/account.service'
10 import { first, tap } from 'rxjs/operators'
11 import { I18n } from '@ngx-translate/i18n-polyfill'
12 import { Subscription } from 'rxjs'
13 import { ScreenService } from '@app/shared/misc/screen.service'
14 import { Notifier, ServerService } from '@app/core'
17 selector: 'my-account-videos',
18 templateUrl: '../../shared/video/abstract-video-list.html',
20 '../../shared/video/abstract-video-list.scss',
21 './account-videos.component.scss'
24 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
28 private account: Account
29 private accountSub: Subscription
33 protected router: Router,
34 protected serverService: ServerService,
35 protected route: ActivatedRoute,
36 protected authService: AuthService,
37 protected notifier: Notifier,
38 protected confirmService: ConfirmService,
39 protected screenService: ScreenService,
40 private accountService: AccountService,
41 private videoService: VideoService
49 // Parent get the account for us
50 this.accountSub = this.accountService.accountLoaded
52 .subscribe(account => {
53 this.account = account
56 this.generateSyndicationList()
61 if (this.accountSub) this.accountSub.unsubscribe()
66 getVideosObservable (page: number) {
67 const newPagination = immutableAssign(this.pagination, { currentPage: page })
69 return this.videoService
70 .getAccountVideos(this.account, newPagination, this.sort)
73 this.titlePage = this.i18n('Published {{total}} videos', { total })
78 generateSyndicationList () {
79 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)