]>
Commit | Line | Data |
---|---|---|
07f81d9d | 1 | import { forkJoin, Subscription } from 'rxjs' |
67ed6552 | 2 | import { first, tap } from 'rxjs/operators' |
5bcbcbe3 | 3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' |
0626e7af | 4 | import { ActivatedRoute, Router } from '@angular/router' |
67ed6552 C |
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' | |
0aa52e17 | 9 | import { VideoFilter } from '@shared/models' |
0626e7af C |
10 | |
11 | @Component({ | |
12 | selector: 'my-account-videos', | |
67ed6552 | 13 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html', |
0626e7af | 14 | styleUrls: [ |
ae2dd046 | 15 | '../../shared/shared-video-miniature/abstract-video-list.scss' |
0626e7af C |
16 | ] |
17 | }) | |
18 | export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
4363ce0e | 19 | // No value because we don't want a page title |
b1d40cff | 20 | titlePage: string |
0626e7af | 21 | loadOnInit = false |
07f81d9d | 22 | loadUserVideoPreferences = true |
0626e7af | 23 | |
0aa52e17 C |
24 | filter: VideoFilter = null |
25 | ||
0626e7af | 26 | private account: Account |
734a5ceb | 27 | private accountSub: Subscription |
0626e7af C |
28 | |
29 | constructor ( | |
30 | protected router: Router, | |
489290b8 | 31 | protected serverService: ServerService, |
0626e7af C |
32 | protected route: ActivatedRoute, |
33 | protected authService: AuthService, | |
d3217560 | 34 | protected userService: UserService, |
f8b2c1b4 | 35 | protected notifier: Notifier, |
0626e7af | 36 | protected confirmService: ConfirmService, |
bbe0f064 | 37 | protected screenService: ScreenService, |
d3217560 | 38 | protected storageService: LocalStorageService, |
0626e7af | 39 | private accountService: AccountService, |
5bcbcbe3 RK |
40 | private videoService: VideoService, |
41 | protected cfr: ComponentFactoryResolver | |
0626e7af C |
42 | ) { |
43 | super() | |
44 | } | |
45 | ||
46 | ngOnInit () { | |
47 | super.ngOnInit() | |
48 | ||
0aa52e17 C |
49 | this.enableAllFilterIfPossible() |
50 | ||
0626e7af | 51 | // Parent get the account for us |
07f81d9d C |
52 | this.accountSub = forkJoin([ |
53 | this.accountService.accountLoaded.pipe(first()), | |
54 | this.onUserLoadedSubject.pipe(first()) | |
55 | ]).subscribe(([ account ]) => { | |
56 | this.account = account | |
0626e7af | 57 | |
07f81d9d C |
58 | this.reloadVideos() |
59 | this.generateSyndicationList() | |
60 | }) | |
0626e7af C |
61 | } |
62 | ||
63 | ngOnDestroy () { | |
734a5ceb C |
64 | if (this.accountSub) this.accountSub.unsubscribe() |
65 | ||
0626e7af C |
66 | super.ngOnDestroy() |
67 | } | |
68 | ||
69 | getVideosObservable (page: number) { | |
70 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
0aa52e17 C |
71 | const options = { |
72 | account: this.account, | |
73 | videoPagination: newPagination, | |
74 | sort: this.sort, | |
75 | nsfwPolicy: this.nsfwPolicy, | |
76 | videoFilter: this.filter | |
77 | } | |
0626e7af | 78 | |
0bf1f265 | 79 | return this.videoService |
0aa52e17 | 80 | .getAccountVideos(options) |
0626e7af C |
81 | } |
82 | ||
0aa52e17 C |
83 | toggleModerationDisplay () { |
84 | this.filter = this.buildLocalFilter(this.filter, null) | |
85 | ||
86 | this.reloadVideos() | |
87 | } | |
88 | ||
0626e7af C |
89 | generateSyndicationList () { |
90 | this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id) | |
91 | } | |
4d5e572f C |
92 | |
93 | displayAsRow () { | |
94 | return this.screenService.isInMobileView() | |
95 | } | |
0626e7af | 96 | } |