]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - 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
1 import { Subscription } from 'rxjs'
2 import { first, tap } from 'rxjs/operators'
3 import { Component, OnDestroy, OnInit } from '@angular/core'
4 import { ActivatedRoute, Router } from '@angular/router'
5 import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
6 import { immutableAssign } from '@app/helpers'
7 import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
9 import { I18n } from '@ngx-translate/i18n-polyfill'
10
11 @Component({
12 selector: 'my-account-videos',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
14 styleUrls: [
15 '../../shared/shared-video-miniature/abstract-video-list.scss'
16 ]
17 })
18 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
20 loadOnInit = false
21
22 private account: Account
23 private accountSub: Subscription
24
25 constructor (
26 protected i18n: I18n,
27 protected router: Router,
28 protected serverService: ServerService,
29 protected route: ActivatedRoute,
30 protected authService: AuthService,
31 protected userService: UserService,
32 protected notifier: Notifier,
33 protected confirmService: ConfirmService,
34 protected screenService: ScreenService,
35 protected storageService: LocalStorageService,
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
46 this.accountSub = this.accountService.accountLoaded
47 .pipe(first())
48 .subscribe(account => {
49 this.account = account
50
51 this.reloadVideos()
52 this.generateSyndicationList()
53 })
54 }
55
56 ngOnDestroy () {
57 if (this.accountSub) this.accountSub.unsubscribe()
58
59 super.ngOnDestroy()
60 }
61
62 getVideosObservable (page: number) {
63 const newPagination = immutableAssign(this.pagination, { currentPage: page })
64
65 return this.videoService
66 .getAccountVideos(this.account, newPagination, this.sort)
67 .pipe(
68 tap(({ total }) => {
69 this.titlePage = this.i18n('Published {{total}} videos', { total })
70 })
71 )
72 }
73
74 generateSyndicationList () {
75 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
76 }
77 }