aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+accounts/account-videos/account-videos.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+accounts/account-videos/account-videos.component.ts')
-rw-r--r--client/src/app/+accounts/account-videos/account-videos.component.ts93
1 files changed, 33 insertions, 60 deletions
diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts
index 4ab6d2147..13d1f857d 100644
--- a/client/src/app/+accounts/account-videos/account-videos.component.ts
+++ b/client/src/app/+accounts/account-videos/account-videos.component.ts
@@ -1,96 +1,69 @@
1import { forkJoin, Subscription } from 'rxjs' 1import { Subscription } from 'rxjs'
2import { first } from 'rxjs/operators' 2import { first } from 'rxjs/operators'
3import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' 3import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
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' 5import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8import { AbstractVideoList } from '@app/shared/shared-video-miniature' 6import { VideoFilters } from '@app/shared/shared-video-miniature'
9import { VideoFilter } from '@shared/models' 7import { VideoSortField } from '@shared/models'
10 8
11@Component({ 9@Component({
12 selector: 'my-account-videos', 10 selector: 'my-account-videos',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html', 11 templateUrl: './account-videos.component.html'
14 styleUrls: [
15 '../../shared/shared-video-miniature/abstract-video-list.scss'
16 ]
17}) 12})
18export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { 13export class AccountVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
19 // No value because we don't want a page title 14 getVideosObservableFunction = this.getVideosObservable.bind(this)
20 titlePage: string 15 getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
21 loadOnInit = false
22 loadUserVideoPreferences = true
23 16
24 filter: VideoFilter = null 17 title = $localize`Videos`
18 defaultSort = '-publishedAt' as VideoSortField
19
20 account: Account
21 disabled = false
25 22
26 private account: Account
27 private accountSub: Subscription 23 private accountSub: Subscription
28 24
29 constructor ( 25 constructor (
30 protected router: Router, 26 private screenService: ScreenService,
31 protected serverService: ServerService,
32 protected route: ActivatedRoute,
33 protected authService: AuthService,
34 protected userService: UserService,
35 protected notifier: Notifier,
36 protected confirmService: ConfirmService,
37 protected screenService: ScreenService,
38 protected storageService: LocalStorageService,
39 private accountService: AccountService, 27 private accountService: AccountService,
40 private videoService: VideoService, 28 private videoService: VideoService
41 protected cfr: ComponentFactoryResolver
42 ) { 29 ) {
43 super()
44 } 30 }
45 31
46 ngOnInit () { 32 ngOnInit () {
47 super.ngOnInit()
48
49 this.enableAllFilterIfPossible()
50
51 // Parent get the account for us 33 // Parent get the account for us
52 this.accountSub = forkJoin([ 34 this.accountService.accountLoaded.pipe(first())
53 this.accountService.accountLoaded.pipe(first()), 35 .subscribe(account => this.account = account)
54 this.onUserLoadedSubject.pipe(first())
55 ]).subscribe(([ account ]) => {
56 this.account = account
57
58 this.reloadVideos()
59 this.generateSyndicationList()
60 })
61 } 36 }
62 37
63 ngOnDestroy () { 38 ngOnDestroy () {
64 if (this.accountSub) this.accountSub.unsubscribe() 39 if (this.accountSub) this.accountSub.unsubscribe()
65
66 super.ngOnDestroy()
67 } 40 }
68 41
69 getVideosObservable (page: number) { 42 getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) {
70 const newPagination = immutableAssign(this.pagination, { currentPage: page })
71 const options = { 43 const options = {
44 ...filters.toVideosAPIObject(),
45
46 videoPagination: pagination,
72 account: this.account, 47 account: this.account,
73 videoPagination: newPagination, 48 skipCount: true
74 sort: this.sort,
75 nsfwPolicy: this.nsfwPolicy,
76 videoFilter: this.filter
77 } 49 }
78 50
79 return this.videoService 51 return this.videoService.getAccountVideos(options)
80 .getAccountVideos(options)
81 } 52 }
82 53
83 toggleModerationDisplay () { 54 getSyndicationItems () {
84 this.filter = this.buildLocalFilter(this.filter, null) 55 return this.videoService.getAccountFeedUrls(this.account.id)
56 }
85 57
86 this.reloadVideos() 58 displayAsRow () {
59 return this.screenService.isInMobileView()
87 } 60 }
88 61
89 generateSyndicationList () { 62 disableForReuse () {
90 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id) 63 this.disabled = true
91 } 64 }
92 65
93 displayAsRow () { 66 enabledForReuse () {
94 return this.screenService.isInMobileView() 67 this.disabled = false
95 } 68 }
96} 69}