Use frontend peertubeHelpers.getBaseRouterRoute when available.

This commit is contained in:
John Livingston 2021-06-02 15:18:09 +02:00
parent 228a60ca3a
commit 22f392d838
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,8 @@ interface RegisterClientHookOptions {
interface RegisterClientHelpers { interface RegisterClientHelpers {
getBaseStaticRoute: () => string getBaseStaticRoute: () => string
// NB: getBaseRouterRoute will come with Peertube > 3.2.1 (3.3.0?)
getBaseRouterRoute?: () => string
isLoggedIn: () => boolean isLoggedIn: () => boolean
getSettings: () => Promise<{ [ name: string ]: string }> getSettings: () => Promise<{ [ name: string ]: string }>
notifier: { notifier: {

View File

@ -17,7 +17,10 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void {
let settings: any = {} let settings: any = {}
function getBaseRoute (): string { function getBaseRoute (): string {
// FIXME: should be provided by PeertubeHelpers (does not exists for now) // NB: this will come with Peertube > 3.2.1 (3.3.0?)
if (peertubeHelpers.getBaseRouterRoute) {
return peertubeHelpers.getBaseRouterRoute()
}
// We are guessing the route with the correct plugin version with this trick: // We are guessing the route with the correct plugin version with this trick:
const staticBase = peertubeHelpers.getBaseStaticRoute() const staticBase = peertubeHelpers.getBaseStaticRoute()
// we can't use '/plugins/livechat/router', because the loaded html page needs correct relative paths. // we can't use '/plugins/livechat/router', because the loaded html page needs correct relative paths.