]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+accounts/account-videos/account-videos.component.ts
Add plugin table migration table
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
... / ...
CommitLineData
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
4import { AuthService } from '../../core/auth'
5import { ConfirmService } from '../../core/confirm'
6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7import { VideoService } from '../../shared/video/video.service'
8import { Account } from '@app/shared/account/account.model'
9import { AccountService } from '@app/shared/account/account.service'
10import { first, tap } from 'rxjs/operators'
11import { I18n } from '@ngx-translate/i18n-polyfill'
12import { Subscription } from 'rxjs'
13import { ScreenService } from '@app/shared/misc/screen.service'
14import { Notifier, ServerService } from '@app/core'
15
16@Component({
17 selector: 'my-account-videos',
18 templateUrl: '../../shared/video/abstract-video-list.html',
19 styleUrls: [
20 '../../shared/video/abstract-video-list.scss',
21 './account-videos.component.scss'
22 ]
23})
24export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
25 titlePage: string
26 loadOnInit = false
27
28 private account: Account
29 private accountSub: Subscription
30
31 constructor (
32 protected i18n: I18n,
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
42 ) {
43 super()
44 }
45
46 ngOnInit () {
47 super.ngOnInit()
48
49 // Parent get the account for us
50 this.accountSub = this.accountService.accountLoaded
51 .pipe(first())
52 .subscribe(account => {
53 this.account = account
54
55 this.reloadVideos()
56 this.generateSyndicationList()
57 })
58 }
59
60 ngOnDestroy () {
61 if (this.accountSub) this.accountSub.unsubscribe()
62
63 super.ngOnDestroy()
64 }
65
66 getVideosObservable (page: number) {
67 const newPagination = immutableAssign(this.pagination, { currentPage: page })
68
69 return this.videoService
70 .getAccountVideos(this.account, newPagination, this.sort)
71 .pipe(
72 tap(({ totalVideos }) => {
73 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
74 })
75 )
76 }
77
78 generateSyndicationList () {
79 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
80 }
81}