]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-videos/account-videos.component.ts
Reorganize client shared modules
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
CommitLineData
67ed6552
C
1import { Subscription } from 'rxjs'
2import { first, tap } from 'rxjs/operators'
0626e7af
C
3import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router'
67ed6552
C
5import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
6import { immutableAssign } from '@app/helpers'
7import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8import { AbstractVideoList } from '@app/shared/shared-video-miniature'
b1d40cff 9import { I18n } from '@ngx-translate/i18n-polyfill'
0626e7af
C
10
11@Component({
12 selector: 'my-account-videos',
67ed6552 13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
0626e7af 14 styleUrls: [
67ed6552 15 '../../shared/shared-video-miniature/abstract-video-list.scss',
0626e7af
C
16 './account-videos.component.scss'
17 ]
18})
19export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 20 titlePage: string
0626e7af
C
21 loadOnInit = false
22
23 private account: Account
734a5ceb 24 private accountSub: Subscription
0626e7af
C
25
26 constructor (
34c7f429 27 protected i18n: I18n,
0626e7af 28 protected router: Router,
489290b8 29 protected serverService: ServerService,
0626e7af
C
30 protected route: ActivatedRoute,
31 protected authService: AuthService,
d3217560 32 protected userService: UserService,
f8b2c1b4 33 protected notifier: Notifier,
0626e7af 34 protected confirmService: ConfirmService,
bbe0f064 35 protected screenService: ScreenService,
d3217560 36 protected storageService: LocalStorageService,
0626e7af
C
37 private accountService: AccountService,
38 private videoService: VideoService
39 ) {
40 super()
41 }
42
43 ngOnInit () {
44 super.ngOnInit()
45
46 // Parent get the account for us
734a5ceb 47 this.accountSub = this.accountService.accountLoaded
722bca90
C
48 .pipe(first())
49 .subscribe(account => {
50 this.account = account
0626e7af 51
722bca90
C
52 this.reloadVideos()
53 this.generateSyndicationList()
54 })
0626e7af
C
55 }
56
57 ngOnDestroy () {
734a5ceb
C
58 if (this.accountSub) this.accountSub.unsubscribe()
59
0626e7af
C
60 super.ngOnDestroy()
61 }
62
63 getVideosObservable (page: number) {
64 const newPagination = immutableAssign(this.pagination, { currentPage: page })
65
0bf1f265
C
66 return this.videoService
67 .getAccountVideos(this.account, newPagination, this.sort)
b1d40cff 68 .pipe(
93cae479
C
69 tap(({ total }) => {
70 this.titlePage = this.i18n('Published {{total}} videos', { total })
b1d40cff
C
71 })
72 )
0626e7af
C
73 }
74
75 generateSyndicationList () {
76 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
77 }
78}