From 93cae47925e4dd68b7d34a41927b2740b4fab1b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 22 Jul 2019 15:40:13 +0200 Subject: Add client hooks --- shared/models/plugins/client-hook.model.ts | 39 +++++++++++++++++++++++ shared/models/plugins/plugin-client-scope.type.ts | 1 + shared/models/plugins/plugin-scope.type.ts | 1 - shared/models/plugins/server-hook.model.ts | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 shared/models/plugins/client-hook.model.ts create mode 100644 shared/models/plugins/plugin-client-scope.type.ts delete mode 100644 shared/models/plugins/plugin-scope.type.ts (limited to 'shared/models/plugins') diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts new file mode 100644 index 000000000..89400003e --- /dev/null +++ b/shared/models/plugins/client-hook.model.ts @@ -0,0 +1,39 @@ +export type ClientFilterHookName = + 'filter:api.videos.list.trending.params' | + 'filter:api.videos.list.trending.result' | + + 'filter:api.videos.list.local.params' | + 'filter:api.videos.list.local.result' | + + 'filter:api.videos.list.recently-added.params' | + 'filter:api.videos.list.recently-added.result' | + + 'filter:api.videos.list.user-subscriptions.params' | + 'filter:api.videos.list.user-subscriptions.result' | + + 'filter:api.video-watch.video.get.params' | + 'filter:api.video-watch.video.get.result' | + + 'filter:api.video-watch.video-threads.list.params' | + 'filter:api.video-watch.video-threads.list.result' | + + 'filter:api.video-watch.video-thread-replies.list.params' | + 'filter:api.video-watch.video-thread-replies.list.result' | + + 'filter:api.search.videos.list.params' | + 'filter:api.search.videos.list.result' | + 'filter:api.search.video-channels.list.params' | + 'filter:api.search.video-channels.list.result' + +export type ClientActionHookName = + 'action:application.init' | + + 'action:video-watch.init' | + + 'action:video-watch.video.loaded' + +export type ClientHookName = ClientActionHookName | ClientFilterHookName + +export interface ClientHook { + runHook (hookName: ClientHookName, result?: T, params?: any): Promise +} diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/plugin-client-scope.type.ts new file mode 100644 index 000000000..a2112eed7 --- /dev/null +++ b/shared/models/plugins/plugin-client-scope.type.ts @@ -0,0 +1 @@ +export type PluginClientScope = 'common' | 'video-watch' diff --git a/shared/models/plugins/plugin-scope.type.ts b/shared/models/plugins/plugin-scope.type.ts deleted file mode 100644 index b63ae43ec..000000000 --- a/shared/models/plugins/plugin-scope.type.ts +++ /dev/null @@ -1 +0,0 @@ -export type PluginScope = 'common' | 'video-watch' diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts index a7f88f3c4..6729e2dab 100644 --- a/shared/models/plugins/server-hook.model.ts +++ b/shared/models/plugins/server-hook.model.ts @@ -30,5 +30,5 @@ export type ServerActionHookName = export type ServerHookName = ServerFilterHookName | ServerActionHookName export interface ServerHook { - runHook (hookName: ServerHookName, params?: any) + runHook (hookName: ServerHookName, result?: T, params?: any): Promise } -- cgit v1.2.3