]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/plugins/plugin.service.ts
Lazy load static objects
[github/Chocobozzz/PeerTube.git] / client / src / app / core / plugins / plugin.service.ts
index 3af36765af795ed8de83fbac93b4ccd25add3242..da5114048a994a896c790688ce88a6860dbad27d 100644 (file)
@@ -12,6 +12,7 @@ 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'
@@ -42,7 +43,8 @@ export class PluginService implements ClientHook {
   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>
@@ -57,6 +59,7 @@ export class PluginService implements ClientHook {
 
   constructor (
     private router: Router,
+    private authService: AuthService,
     private server: ServerService,
     private zone: NgZone,
     private authHttp: HttpClient,
@@ -67,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()
 
@@ -265,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]))