From 640712769efdca7f4f140005fd248ebbf2356345 Mon Sep 17 00:00:00 2001 From: matty Date: Wed, 2 Apr 2025 12:23:34 -0400 Subject: [PATCH] add sidebar link --- client/common-client-plugin.js | 47 ++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/client/common-client-plugin.js b/client/common-client-plugin.js index 3c5ee23..2c1d6eb 100644 --- a/client/common-client-plugin.js +++ b/client/common-client-plugin.js @@ -7,7 +7,6 @@ async function register({ peertubeHelpers, registerClientRoute, }) { - /** * Add link admin page */ @@ -39,27 +38,65 @@ async function register({ }, }); + registerHook({ + target: "filter:left-menu.links.create.result", + handler: (links) => { + if (!Array.isArray(links)) { + return links; + } + let myLibraryLinks; + // Searching the 'in-my-library' entry. + for (const link of links) { + if (typeof link !== "object") { + continue; + } + if (!("key" in link)) { + continue; + } + if (link.key === "in-my-library" || link.key === "my-video-space") { + myLibraryLinks = link; + break; + } + } + if (!myLibraryLinks) { + return links; + } + if (!Array.isArray(myLibraryLinks.links)) { + return links; + } + + const label = "NCTV Storage"; + myLibraryLinks.links.unshift({ + label, + shortLabel: label, + path: "/p/ncd-my-subscription", + icon: "trending", + }); + return links; + }, + }); + // Register routes registerClientRoute({ route: "ncd-my-subscription", onMount: ({ rootEl }) => { - subPage.showPage({rootEl, peertubeHelpers}); + subPage.showPage({ rootEl, peertubeHelpers }); }, }); registerClientRoute({ route: "ncd-subscription-success", onMount: ({ rootEl }) => { - successPage.showPage({rootEl, peertubeHelpers}); + successPage.showPage({ rootEl, peertubeHelpers }); }, }); registerClientRoute({ route: "ncd-subscription-cancel", onMount: ({ rootEl }) => { - cancelPage.showPage({rootEl, peertubeHelpers}); + cancelPage.showPage({ rootEl, peertubeHelpers }); }, }); } -export { register }; \ No newline at end of file +export { register };