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, Notifier } from '@app/core'
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
pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
common: new ReplaySubject<boolean>(1),
search: new ReplaySubject<boolean>(1),
- 'video-watch': new ReplaySubject<boolean>(1)
+ 'video-watch': new ReplaySubject<boolean>(1),
+ signup: new ReplaySubject<boolean>(1)
}
translationsObservable: Observable<PluginTranslation>
constructor (
private router: Router,
+ private authService: AuthService,
+ private notifier: Notifier,
private server: ServerService,
private zone: NgZone,
private authHttp: HttpClient,
}
initializePlugins () {
- this.server.configLoaded
- .subscribe(() => {
- this.plugins = this.server.getConfig().plugin.registered
+ this.server.getConfig()
+ .subscribe(config => {
+ this.plugins = config.plugin.registered
this.buildScopeStruct()
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))
.toPromise()
},
+ isLoggedIn: () => {
+ return this.authService.isLoggedIn()
+ },
+
+ notifier: this.notifier,
+
translate: (value: string) => {
return this.translationsObservable
.pipe(map(allTranslations => allTranslations[npmName]))