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