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