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