X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fplugins%2Fplugin.service.ts;h=da5114048a994a896c790688ce88a6860dbad27d;hb=ba430d7516bc5b1324b60571ba7594460969b7fb;hp=3bb82e8a987f8b32d008a8465d7cc37aad6718d4;hpb=d75db01f14138ea660c4c519e37ab05228b39d13;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 3bb82e8a9..da5114048 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -12,12 +12,14 @@ import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plu import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type' import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' import { HttpClient } from '@angular/common/http' +import { AuthService } from '@app/core/auth' import { RestExtractor } from '@app/shared/rest' import { PluginType } from '@shared/models/plugins/plugin.type' import { PublicServerSetting } from '@shared/models/plugins/public-server.setting' import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' import { RegisterClientHelpers } from '../../../types/register-client-option.model' import { PluginTranslation } from '@shared/models/plugins/plugin-translation.model' +import { importModule } from '@app/shared/misc/utils' interface HookStructValue extends RegisterClientHookOptions { plugin: ServerConfigPlugin @@ -41,7 +43,8 @@ export class PluginService implements ClientHook { pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject } = { common: new ReplaySubject(1), search: new ReplaySubject(1), - 'video-watch': new ReplaySubject(1) + 'video-watch': new ReplaySubject(1), + signup: new ReplaySubject(1) } translationsObservable: Observable @@ -56,6 +59,7 @@ export class PluginService implements ClientHook { constructor ( private router: Router, + private authService: AuthService, private server: ServerService, private zone: NgZone, private authHttp: HttpClient, @@ -66,9 +70,9 @@ export class PluginService implements ClientHook { } initializePlugins () { - this.server.configLoaded - .subscribe(() => { - this.plugins = this.server.getConfig().plugin.registered + this.server.getConfig() + .subscribe(config => { + this.plugins = config.plugin.registered this.buildScopeStruct() @@ -222,7 +226,7 @@ export class PluginService implements ClientHook { console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) return this.zone.runOutsideAngular(() => { - return import(/* webpackIgnore: true */ clientScript.script) + return importModule(clientScript.script) .then((script: ClientScriptModule) => script.register({ registerHook, peertubeHelpers })) .then(() => this.sortHooksByPriority()) .catch(err => console.error('Cannot import or register plugin %s.', pluginInfo.plugin.name, err)) @@ -264,6 +268,10 @@ export class PluginService implements ClientHook { .toPromise() }, + isLoggedIn: () => { + return this.authService.isLoggedIn() + }, + translate: (value: string) => { return this.translationsObservable .pipe(map(allTranslations => allTranslations[npmName]))