diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-03 10:39:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-03 10:39:40 +0200 |
commit | 9ca0f688e9e8558233f1a538b96a43da44e35353 (patch) | |
tree | 16370ffe97df1bfeef874ce71fa6bedff0b7496b /client/src/app/+video-channels | |
parent | 0b6f531653a7a24f82ad65564479a70a9326301a (diff) | |
download | PeerTube-9ca0f688e9e8558233f1a538b96a43da44e35353.tar.gz PeerTube-9ca0f688e9e8558233f1a538b96a43da44e35353.tar.zst PeerTube-9ca0f688e9e8558233f1a538b96a43da44e35353.zip |
Add channel hooks
Diffstat (limited to 'client/src/app/+video-channels')
3 files changed, 41 insertions, 18 deletions
diff --git a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts index 14465bb8d..82af65026 100644 --- a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts +++ b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Subject, Subscription } from 'rxjs' | 1 | import { Subject, Subscription } from 'rxjs' |
2 | import { Component, OnDestroy, OnInit } from '@angular/core' | 2 | import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core' |
3 | import { ComponentPagination, hasMoreItems, ScreenService } from '@app/core' | 3 | import { ComponentPagination, hasMoreItems, HooksService, ScreenService } from '@app/core' |
4 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' | 4 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' |
5 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' | 5 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' |
6 | 6 | ||
@@ -9,7 +9,7 @@ import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-pl | |||
9 | templateUrl: './video-channel-playlists.component.html', | 9 | templateUrl: './video-channel-playlists.component.html', |
10 | styleUrls: [ './video-channel-playlists.component.scss' ] | 10 | styleUrls: [ './video-channel-playlists.component.scss' ] |
11 | }) | 11 | }) |
12 | export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { | 12 | export class VideoChannelPlaylistsComponent implements OnInit, AfterViewInit, OnDestroy { |
13 | videoPlaylists: VideoPlaylist[] = [] | 13 | videoPlaylists: VideoPlaylist[] = [] |
14 | 14 | ||
15 | pagination: ComponentPagination = { | 15 | pagination: ComponentPagination = { |
@@ -26,16 +26,24 @@ export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { | |||
26 | constructor ( | 26 | constructor ( |
27 | private videoPlaylistService: VideoPlaylistService, | 27 | private videoPlaylistService: VideoPlaylistService, |
28 | private videoChannelService: VideoChannelService, | 28 | private videoChannelService: VideoChannelService, |
29 | private screenService: ScreenService | 29 | private screenService: ScreenService, |
30 | private hooks: HooksService | ||
30 | ) {} | 31 | ) {} |
31 | 32 | ||
32 | ngOnInit () { | 33 | ngOnInit () { |
33 | // Parent get the video channel for us | 34 | // Parent get the video channel for us |
34 | this.videoChannelSub = this.videoChannelService.videoChannelLoaded | 35 | this.videoChannelSub = this.videoChannelService.videoChannelLoaded |
35 | .subscribe(videoChannel => { | 36 | .subscribe(videoChannel => { |
36 | this.videoChannel = videoChannel | 37 | this.videoChannel = videoChannel |
37 | this.loadVideoPlaylists() | 38 | |
38 | }) | 39 | this.hooks.runAction('action:video-channel-playlists.video-channel.loaded', 'video-channel', { videoChannel }) |
40 | |||
41 | this.loadVideoPlaylists() | ||
42 | }) | ||
43 | } | ||
44 | |||
45 | ngAfterViewInit () { | ||
46 | this.hooks.runAction('action:video-channel-playlists.init', 'video-channel') | ||
39 | } | 47 | } |
40 | 48 | ||
41 | ngOnDestroy () { | 49 | ngOnDestroy () { |
@@ -55,11 +63,13 @@ export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { | |||
55 | 63 | ||
56 | private loadVideoPlaylists () { | 64 | private loadVideoPlaylists () { |
57 | this.videoPlaylistService.listChannelPlaylists(this.videoChannel, this.pagination) | 65 | this.videoPlaylistService.listChannelPlaylists(this.videoChannel, this.pagination) |
58 | .subscribe(res => { | 66 | .subscribe(res => { |
59 | this.videoPlaylists = this.videoPlaylists.concat(res.data) | 67 | this.videoPlaylists = this.videoPlaylists.concat(res.data) |
60 | this.pagination.totalItems = res.total | 68 | this.pagination.totalItems = res.total |
69 | |||
70 | this.hooks.runAction('action:video-channel-playlists.playlists.loaded', 'video-channel', { playlists: this.videoPlaylists }) | ||
61 | 71 | ||
62 | this.onDataSubject.next(res.data) | 72 | this.onDataSubject.next(res.data) |
63 | }) | 73 | }) |
64 | } | 74 | } |
65 | } | 75 | } |
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html index 0a6c5fcb2..9e9e98c99 100644 --- a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html | |||
@@ -19,5 +19,7 @@ | |||
19 | [loadUserVideoPreferences]="true" | 19 | [loadUserVideoPreferences]="true" |
20 | 20 | ||
21 | [disabled]="disabled" | 21 | [disabled]="disabled" |
22 | |||
23 | (videosLoaded)="onVideosLoaded($event)" | ||
22 | > | 24 | > |
23 | </my-videos-list> | 25 | </my-videos-list> |
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts index 43fce475d..5e3946bf5 100644 --- a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts | |||
@@ -1,16 +1,16 @@ | |||
1 | import { Subscription } from 'rxjs' | 1 | import { Subscription } from 'rxjs' |
2 | import { first } from 'rxjs/operators' | 2 | import { first } from 'rxjs/operators' |
3 | import { Component, OnDestroy, OnInit } from '@angular/core' | 3 | import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core' |
4 | import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core' | 4 | import { ComponentPaginationLight, DisableForReuseHook, HooksService, ScreenService } from '@app/core' |
5 | import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' | 5 | import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' |
6 | import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature' | 6 | import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature' |
7 | import { VideoSortField } from '@shared/models/videos' | 7 | import { Video, VideoSortField } from '@shared/models' |
8 | 8 | ||
9 | @Component({ | 9 | @Component({ |
10 | selector: 'my-video-channel-videos', | 10 | selector: 'my-video-channel-videos', |
11 | templateUrl: './video-channel-videos.component.html' | 11 | templateUrl: './video-channel-videos.component.html' |
12 | }) | 12 | }) |
13 | export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableForReuseHook { | 13 | export class VideoChannelVideosComponent implements OnInit, AfterViewInit, OnDestroy, DisableForReuseHook { |
14 | getVideosObservableFunction = this.getVideosObservable.bind(this) | 14 | getVideosObservableFunction = this.getVideosObservable.bind(this) |
15 | getSyndicationItemsFunction = this.getSyndicationItems.bind(this) | 15 | getSyndicationItemsFunction = this.getSyndicationItems.bind(this) |
16 | 16 | ||
@@ -36,7 +36,8 @@ export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableFo | |||
36 | constructor ( | 36 | constructor ( |
37 | private screenService: ScreenService, | 37 | private screenService: ScreenService, |
38 | private videoChannelService: VideoChannelService, | 38 | private videoChannelService: VideoChannelService, |
39 | private videoService: VideoService | 39 | private videoService: VideoService, |
40 | private hooks: HooksService | ||
40 | ) { | 41 | ) { |
41 | } | 42 | } |
42 | 43 | ||
@@ -45,9 +46,15 @@ export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableFo | |||
45 | this.videoChannelService.videoChannelLoaded.pipe(first()) | 46 | this.videoChannelService.videoChannelLoaded.pipe(first()) |
46 | .subscribe(videoChannel => { | 47 | .subscribe(videoChannel => { |
47 | this.videoChannel = videoChannel | 48 | this.videoChannel = videoChannel |
49 | |||
50 | this.hooks.runAction('action:video-channel-videos.video-channel.loaded', 'video-channel', { videoChannel }) | ||
48 | }) | 51 | }) |
49 | } | 52 | } |
50 | 53 | ||
54 | ngAfterViewInit () { | ||
55 | this.hooks.runAction('action:video-channel-videos.init', 'video-channel') | ||
56 | } | ||
57 | |||
51 | ngOnDestroy () { | 58 | ngOnDestroy () { |
52 | if (this.videoChannelSub) this.videoChannelSub.unsubscribe() | 59 | if (this.videoChannelSub) this.videoChannelSub.unsubscribe() |
53 | } | 60 | } |
@@ -79,4 +86,8 @@ export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableFo | |||
79 | enabledForReuse () { | 86 | enabledForReuse () { |
80 | this.disabled = false | 87 | this.disabled = false |
81 | } | 88 | } |
89 | |||
90 | onVideosLoaded (videos: Video[]) { | ||
91 | this.hooks.runAction('action:video-channel-videos.videos.loaded', 'video-channel', { videos }) | ||
92 | } | ||
82 | } | 93 | } |