]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-videos/account-videos.component.ts
Translated using Weblate (German)
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
CommitLineData
dd24f1bb 1import { Subscription } from 'rxjs'
9df52d66 2import { first } from 'rxjs/operators'
dd24f1bb
C
3import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
67ed6552 5import { Account, AccountService, VideoService } from '@app/shared/shared-main'
dd24f1bb
C
6import { VideoFilters } from '@app/shared/shared-video-miniature'
7import { VideoSortField } from '@shared/models'
0626e7af
C
8
9@Component({
10 selector: 'my-account-videos',
dd24f1bb 11 templateUrl: './account-videos.component.html'
0626e7af 12})
dd24f1bb
C
13export class AccountVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
14 getVideosObservableFunction = this.getVideosObservable.bind(this)
15 getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
0626e7af 16
dd24f1bb
C
17 title = $localize`Videos`
18 defaultSort = '-publishedAt' as VideoSortField
19
20 account: Account
21 disabled = false
0aa52e17 22
734a5ceb 23 private accountSub: Subscription
0626e7af
C
24
25 constructor (
dd24f1bb 26 private screenService: ScreenService,
0626e7af 27 private accountService: AccountService,
dd24f1bb 28 private videoService: VideoService
0626e7af 29 ) {
0626e7af
C
30 }
31
32 ngOnInit () {
0626e7af 33 // Parent get the account for us
dd24f1bb
C
34 this.accountService.accountLoaded.pipe(first())
35 .subscribe(account => this.account = account)
0626e7af
C
36 }
37
38 ngOnDestroy () {
734a5ceb 39 if (this.accountSub) this.accountSub.unsubscribe()
0626e7af
C
40 }
41
dd24f1bb 42 getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) {
0aa52e17 43 const options = {
dd24f1bb
C
44 ...filters.toVideosAPIObject(),
45
46 videoPagination: pagination,
0aa52e17 47 account: this.account,
dd24f1bb 48 skipCount: true
0aa52e17 49 }
0626e7af 50
dd24f1bb 51 return this.videoService.getAccountVideos(options)
0626e7af
C
52 }
53
dd24f1bb
C
54 getSyndicationItems () {
55 return this.videoService.getAccountFeedUrls(this.account.id)
56 }
0aa52e17 57
dd24f1bb
C
58 displayAsRow () {
59 return this.screenService.isInMobileView()
0aa52e17
C
60 }
61
dd24f1bb
C
62 disableForReuse () {
63 this.disabled = true
0626e7af 64 }
4d5e572f 65
dd24f1bb
C
66 enabledForReuse () {
67 this.disabled = false
4d5e572f 68 }
0626e7af 69}