From a8b0d684ba31db20a8b984c747a9987a229e681f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Dec 2021 15:15:38 +0100 Subject: [PATCH] Add registerClientRoute --- .../client/common-client-plugin.js | 20 +++++++++++++++++-- .../client/video-watch-client-plugin.js | 13 ++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/peertube-plugin-hello-world/client/common-client-plugin.js b/peertube-plugin-hello-world/client/common-client-plugin.js index 85edaaa..4337651 100644 --- a/peertube-plugin-hello-world/client/common-client-plugin.js +++ b/peertube-plugin-hello-world/client/common-client-plugin.js @@ -1,4 +1,4 @@ -function register ({ registerHook, registerSettingsScript, peertubeHelpers }) { +function register ({ registerHook, registerSettingsScript, registerClientRoute, peertubeHelpers }) { registerHook({ target: 'action:application.init', handler: () => onApplicationInit(peertubeHelpers) @@ -88,11 +88,18 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }) { key: 'in-my-stuff', title: 'In my stuff', links: [ - { + { path: '/about', icon: 'alert', shortLabel: 'About', label: 'About' + }, + + { + path: peertubeHelpers.getBasePluginClientPath() + '/my-super/route', + icon: '', + shortLabel: 'super route', + label: 'Super route' } ] } @@ -138,6 +145,15 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }) { return false } }) + + // Routes + + registerClientRoute({ + route: 'my-super/route', + onMount: ({ rootEl }) => { + rootEl.innerHTML = 'hello' + } + }) } export { diff --git a/peertube-plugin-hello-world/client/video-watch-client-plugin.js b/peertube-plugin-hello-world/client/video-watch-client-plugin.js index 49ad1af..49c46ba 100644 --- a/peertube-plugin-hello-world/client/video-watch-client-plugin.js +++ b/peertube-plugin-hello-world/client/video-watch-client-plugin.js @@ -71,6 +71,19 @@ function register ({ registerHook, peertubeHelpers }) { } }) + for (const hook of [ + 'filter:api.video-watch.video-playlist-elements.get.result' + ]) { + registerHook({ + target: hook, + handler: (result) => { + console.log('Running hook %s', hook, result) + + return result + } + }) + } + peertubeHelpers.notifier.info('you are on the watch page', 'useless', 1000) }