Log error on unknown hook

This commit is contained in:
Chocobozzz
2019-07-22 16:31:47 +02:00
committed by Chocobozzz
parent e8f902c05c
commit 7663e55a2c
9 changed files with 85 additions and 56 deletions

View File

@@ -8,7 +8,7 @@ import { RegisterHookOptions } from '@shared/models/plugins/register-hook.model'
import { ReplaySubject } from 'rxjs'
import { first, shareReplay } from 'rxjs/operators'
import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
import { ClientHook, ClientHookName } from '@shared/models/plugins/client-hook.model'
import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plugins/client-hook.model'
import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'
interface HookStructValue extends RegisterHookOptions {
@@ -155,6 +155,11 @@ export class PluginService implements ClientHook {
const { plugin, clientScript } = pluginInfo
const registerHook = (options: RegisterHookOptions) => {
if (clientHookObject[options.target] !== true) {
console.error('Unknown hook %s of plugin %s. Skipping.', options.target, plugin.name)
return
}
if (!this.hooks[options.target]) this.hooks[options.target] = []
this.hooks[options.target].push({

View File

@@ -79,6 +79,8 @@ export class SearchComponent implements OnInit, OnDestroy {
err => this.notifier.error(err.text)
)
this.hooks.runAction('action:search.init')
}
ngOnDestroy () {

View File

@@ -69,8 +69,8 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
this.videoService.getVideos.bind(this.videoService),
params,
'common',
'filter:api.videos.list.local.params',
'filter:api.videos.list.local.result'
'filter:api.local-videos.videos.list.params',
'filter:api.local-videos.videos.list.result'
)
}

View File

@@ -61,8 +61,8 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
this.videoService.getVideos.bind(this.videoService),
params,
'common',
'filter:api.videos.list.recently-added.params',
'filter:api.videos.list.recently-added.result'
'filter:api.recently-added-videos.videos.list.params',
'filter:api.recently-added-videos.videos.list.result'
)
}

View File

@@ -74,8 +74,8 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
this.videoService.getVideos.bind(this.videoService),
params,
'common',
'filter:api.videos.list.trending.params',
'filter:api.videos.list.trending.result'
'filter:api.trending-videos.videos.list.params',
'filter:api.trending-videos.videos.list.result'
)
}

View File

@@ -57,8 +57,8 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement
this.videoService.getUserSubscriptionVideos.bind(this.videoService),
params,
'common',
'filter:api.videos.list.user-subscriptions.params',
'filter:api.videos.list.user-subscriptions.result'
'filter:api.user-subscriptions-videos.videos.list.params',
'filter:api.user-subscriptions-videos.videos.list.result'
)
}