this.form.patchValue(settingsValues)
- setTimeout(() => this.hooks.runAction('action:admin-plugin-settings.init', 'admin-plugin', { npmName: this.npmName }))
+ this.hooks.runAction('action:admin-plugin-settings.init', 'admin-plugin', { npmName: this.npmName })
}
private getSetting (name: string) {
import { of } from 'rxjs'
import { switchMap } from 'rxjs/operators'
-import { Component, OnInit } from '@angular/core'
+import { AfterViewInit, Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
-import { AuthService, Notifier } from '@app/core'
+import { AuthService, HooksService, Notifier } from '@app/core'
import {
VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
templateUrl: './video-channel-edit.component.html',
styleUrls: [ './video-channel-edit.component.scss' ]
})
-export class VideoChannelCreateComponent extends VideoChannelEdit implements OnInit {
+export class VideoChannelCreateComponent extends VideoChannelEdit implements OnInit, AfterViewInit {
error: string
videoChannel = new VideoChannel({})
private authService: AuthService,
private notifier: Notifier,
private router: Router,
- private videoChannelService: VideoChannelService
+ private videoChannelService: VideoChannelService,
+ private hooks: HooksService
) {
super()
}
})
}
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-channel-create.init', 'video-channel')
+ }
+
formValidated () {
this.error = undefined
import { Subscription } from 'rxjs'
import { HttpErrorResponse } from '@angular/common/http'
-import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ActivatedRoute, Router } from '@angular/router'
-import { AuthService, Notifier, RedirectService, ServerService } from '@app/core'
+import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core'
+import { ActivatedRoute } from '@angular/router'
+import { AuthService, HooksService, Notifier, RedirectService, ServerService } from '@app/core'
import { genericUploadErrorHandler } from '@app/helpers'
import {
VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
templateUrl: './video-channel-edit.component.html',
styleUrls: [ './video-channel-edit.component.scss' ]
})
-export class VideoChannelUpdateComponent extends VideoChannelEdit implements OnInit, OnDestroy {
+export class VideoChannelUpdateComponent extends VideoChannelEdit implements OnInit, AfterViewInit, OnDestroy {
error: string
videoChannel: VideoChannel
protected formValidatorService: FormValidatorService,
private authService: AuthService,
private notifier: Notifier,
- private router: Router,
private route: ActivatedRoute,
private videoChannelService: VideoChannelService,
private serverService: ServerService,
- private redirectService: RedirectService
+ private redirectService: RedirectService,
+ private hooks: HooksService
) {
super()
}
next: videoChannelToUpdate => {
this.videoChannel = videoChannelToUpdate
+ this.hooks.runAction('action:video-channel-update.video-channel.loaded', 'video-channel', { videoChannel: this.videoChannel })
+
this.oldSupportField = videoChannelToUpdate.support
this.form.patchValue({
})
}
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-channel-update.init', 'video-channel')
+ }
+
ngOnDestroy () {
if (this.paramsSub) this.paramsSub.unsubscribe()
}
import { Subject, Subscription } from 'rxjs'
-import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ComponentPagination, hasMoreItems, ScreenService } from '@app/core'
+import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core'
+import { ComponentPagination, hasMoreItems, HooksService, ScreenService } from '@app/core'
import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
templateUrl: './video-channel-playlists.component.html',
styleUrls: [ './video-channel-playlists.component.scss' ]
})
-export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy {
+export class VideoChannelPlaylistsComponent implements OnInit, AfterViewInit, OnDestroy {
videoPlaylists: VideoPlaylist[] = []
pagination: ComponentPagination = {
constructor (
private videoPlaylistService: VideoPlaylistService,
private videoChannelService: VideoChannelService,
- private screenService: ScreenService
+ private screenService: ScreenService,
+ private hooks: HooksService
) {}
ngOnInit () {
// Parent get the video channel for us
this.videoChannelSub = this.videoChannelService.videoChannelLoaded
- .subscribe(videoChannel => {
- this.videoChannel = videoChannel
- this.loadVideoPlaylists()
- })
+ .subscribe(videoChannel => {
+ this.videoChannel = videoChannel
+
+ this.hooks.runAction('action:video-channel-playlists.video-channel.loaded', 'video-channel', { videoChannel })
+
+ this.loadVideoPlaylists()
+ })
+ }
+
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-channel-playlists.init', 'video-channel')
}
ngOnDestroy () {
private loadVideoPlaylists () {
this.videoPlaylistService.listChannelPlaylists(this.videoChannel, this.pagination)
- .subscribe(res => {
- this.videoPlaylists = this.videoPlaylists.concat(res.data)
- this.pagination.totalItems = res.total
+ .subscribe(res => {
+ this.videoPlaylists = this.videoPlaylists.concat(res.data)
+ this.pagination.totalItems = res.total
+
+ this.hooks.runAction('action:video-channel-playlists.playlists.loaded', 'video-channel', { playlists: this.videoPlaylists })
- this.onDataSubject.next(res.data)
- })
+ this.onDataSubject.next(res.data)
+ })
}
}
[loadUserVideoPreferences]="true"
[disabled]="disabled"
+
+ (videosLoaded)="onVideosLoaded($event)"
>
</my-videos-list>
import { Subscription } from 'rxjs'
import { first } from 'rxjs/operators'
-import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
+import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core'
+import { ComponentPaginationLight, DisableForReuseHook, HooksService, ScreenService } from '@app/core'
import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature'
-import { VideoSortField } from '@shared/models/videos'
+import { Video, VideoSortField } from '@shared/models'
@Component({
selector: 'my-video-channel-videos',
templateUrl: './video-channel-videos.component.html'
})
-export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
+export class VideoChannelVideosComponent implements OnInit, AfterViewInit, OnDestroy, DisableForReuseHook {
getVideosObservableFunction = this.getVideosObservable.bind(this)
getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
constructor (
private screenService: ScreenService,
private videoChannelService: VideoChannelService,
- private videoService: VideoService
+ private videoService: VideoService,
+ private hooks: HooksService
) {
}
this.videoChannelService.videoChannelLoaded.pipe(first())
.subscribe(videoChannel => {
this.videoChannel = videoChannel
+
+ this.hooks.runAction('action:video-channel-videos.video-channel.loaded', 'video-channel', { videoChannel })
})
}
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-channel-videos.init', 'video-channel')
+ }
+
ngOnDestroy () {
if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
}
enabledForReuse () {
this.disabled = false
}
+
+ onVideosLoaded (videos: Video[]) {
+ this.hooks.runAction('action:video-channel-videos.videos.loaded', 'video-channel', { videos })
+ }
}
this.onDataSubject.next(res.data)
- setTimeout(() => this.hooks.runAction('action:video-watch.video-threads.loaded', 'video-watch', { data: this.componentPagination }))
+ this.hooks.runAction('action:video-watch.video-threads.loaded', 'video-watch', { data: this.componentPagination })
},
error: err => this.notifier.error(err.message)
}
runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
- this.pluginService.ensurePluginsAreLoaded(scope)
+ // Use setTimeout to give priority to Angular change detector
+ setTimeout(() => {
+ this.pluginService.ensurePluginsAreLoaded(scope)
.then(() => this.pluginService.runHook(hookName, undefined, params))
.catch((err: any) => logger.error('Fatal hook error.', err))
+ })
}
async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) {
@Input() disabled = false
@Output() filtersChanged = new EventEmitter<VideoFilters>()
+ @Output() videosLoaded = new EventEmitter<Video[]>()
videos: Video[] = []
filters: VideoFilters
if (this.groupByDate) this.buildGroupedDateLabels()
this.onDataSubject.next(data)
+ this.videosLoaded.emit(this.videos)
},
error: err => {
login: new ReplaySubject<boolean>(1),
'video-edit': new ReplaySubject<boolean>(1),
embed: new ReplaySubject<boolean>(1),
- 'my-library': new ReplaySubject<boolean>(1)
+ 'my-library': new ReplaySubject<boolean>(1),
+ 'video-channel': new ReplaySubject<boolean>(1)
}
private readonly peertubeHelpersFactory: PeertubeHelpersFactory
// Fired when a user click on 'View x replies' and they're loaded
'action:video-watch.video-thread-replies.loaded': true,
+ // Fired when the video channel creation page is being initialized
+ 'action:video-channel-create.init': true,
+
+ // Fired when the video channel update page is being initialized
+ 'action:video-channel-update.init': true,
+ 'action:video-channel-update.video-channel.loaded': true,
+
+ // Fired when the page that list video channel videos is being initialized
+ 'action:video-channel-videos.init': true,
+ 'action:video-channel-videos.video-channel.loaded': true,
+ 'action:video-channel-videos.videos.loaded': true,
+
+ // Fired when the page that list video channel playlists is being initialized
+ 'action:video-channel-playlists.init': true,
+ 'action:video-channel-playlists.video-channel.loaded': true,
+ 'action:video-channel-playlists.playlists.loaded': true,
+
// Fired when the video edit page (upload, URL/torrent import, update) is being initialized
'action:video-edit.init': true,
'embed' |
'video-edit' |
'admin-plugin' |
- 'my-library'
+ 'my-library' |
+ 'video-channel'