1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { Location } from '@angular/common'
4 import { immutableAssign } from '@app/shared/misc/utils'
5 import { NotificationsService } from 'angular2-notifications'
6 import { AuthService } from '../../core/auth'
7 import { ConfirmService } from '../../core/confirm'
8 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
9 import { VideoService } from '../../shared/video/video.service'
10 import { Account } from '@app/shared/account/account.model'
11 import { AccountService } from '@app/shared/account/account.service'
12 import { tap } from 'rxjs/operators'
15 selector: 'my-account-videos',
16 templateUrl: '../../shared/video/abstract-video-list.html',
18 '../../shared/video/abstract-video-list.scss',
19 './account-videos.component.scss'
22 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
23 titlePage = 'Published videos'
24 marginContent = false // Disable margin
25 currentRoute = '/account/videos'
28 private account: Account
31 protected router: Router,
32 protected route: ActivatedRoute,
33 protected authService: AuthService,
34 protected notificationsService: NotificationsService,
35 protected confirmService: ConfirmService,
36 protected location: Location,
37 private accountService: AccountService,
38 private videoService: VideoService
46 // Parent get the account for us
47 this.accountService.accountLoaded
48 .subscribe(account => {
49 this.account = account
50 this.currentRoute = '/account/' + this.account.id + '/videos'
52 this.loadMoreVideos(this.pagination.currentPage)
53 this.generateSyndicationList()
61 getVideosObservable (page: number) {
62 const newPagination = immutableAssign(this.pagination, { currentPage: page })
64 return this.videoService
65 .getAccountVideos(this.account, newPagination, this.sort)
66 .pipe(tap(({ totalVideos }) => this.titlePage = `Published ${totalVideos} videos`))
69 generateSyndicationList () {
70 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)