diff options
Diffstat (limited to 'client/src/app/core/plugins/plugin.service.ts')
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index dff8ad864..ccbfd3e4d 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import * as debug from 'debug' | ||
1 | import { Observable, of, ReplaySubject } from 'rxjs' | 2 | import { Observable, of, ReplaySubject } from 'rxjs' |
2 | import { catchError, first, map, shareReplay } from 'rxjs/operators' | 3 | import { catchError, first, map, shareReplay } from 'rxjs/operators' |
3 | import { HttpClient } from '@angular/common/http' | 4 | import { HttpClient } from '@angular/common/http' |
@@ -24,7 +25,6 @@ import { | |||
24 | } from '@shared/models' | 25 | } from '@shared/models' |
25 | import { environment } from '../../../environments/environment' | 26 | import { environment } from '../../../environments/environment' |
26 | import { RegisterClientHelpers } from '../../../types/register-client-option.model' | 27 | import { RegisterClientHelpers } from '../../../types/register-client-option.model' |
27 | import * as debug from 'debug' | ||
28 | 28 | ||
29 | const logger = debug('peertube:plugins') | 29 | const logger = debug('peertube:plugins') |
30 | 30 | ||
@@ -33,8 +33,6 @@ export class PluginService implements ClientHook { | |||
33 | private static BASE_PLUGIN_API_URL = environment.apiUrl + '/api/v1/plugins' | 33 | private static BASE_PLUGIN_API_URL = environment.apiUrl + '/api/v1/plugins' |
34 | private static BASE_PLUGIN_URL = environment.apiUrl + '/plugins' | 34 | private static BASE_PLUGIN_URL = environment.apiUrl + '/plugins' |
35 | 35 | ||
36 | pluginsBuilt = new ReplaySubject<boolean>(1) | ||
37 | |||
38 | pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = { | 36 | pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = { |
39 | common: new ReplaySubject<boolean>(1), | 37 | common: new ReplaySubject<boolean>(1), |
40 | 'admin-plugin': new ReplaySubject<boolean>(1), | 38 | 'admin-plugin': new ReplaySubject<boolean>(1), |
@@ -79,30 +77,18 @@ export class PluginService implements ClientHook { | |||
79 | } | 77 | } |
80 | 78 | ||
81 | initializePlugins () { | 79 | initializePlugins () { |
82 | logger('Building plugin configuration') | 80 | const config = this.server.getHTMLConfig() |
81 | this.plugins = config.plugin.registered | ||
83 | 82 | ||
84 | this.server.getConfig() | 83 | this.buildScopeStruct() |
85 | .subscribe(config => { | ||
86 | this.plugins = config.plugin.registered | ||
87 | 84 | ||
88 | this.buildScopeStruct() | 85 | this.ensurePluginsAreLoaded('common') |
89 | |||
90 | this.pluginsBuilt.next(true) | ||
91 | |||
92 | logger('Plugin configuration built') | ||
93 | }) | ||
94 | } | 86 | } |
95 | 87 | ||
96 | initializeCustomModal (customModal: CustomModalComponent) { | 88 | initializeCustomModal (customModal: CustomModalComponent) { |
97 | this.customModal = customModal | 89 | this.customModal = customModal |
98 | } | 90 | } |
99 | 91 | ||
100 | ensurePluginsAreBuilt () { | ||
101 | return this.pluginsBuilt.asObservable() | ||
102 | .pipe(first(), shareReplay()) | ||
103 | .toPromise() | ||
104 | } | ||
105 | |||
106 | ensurePluginsAreLoaded (scope: PluginClientScope) { | 92 | ensurePluginsAreLoaded (scope: PluginClientScope) { |
107 | this.loadPluginsByScope(scope) | 93 | this.loadPluginsByScope(scope) |
108 | 94 | ||
@@ -156,8 +142,6 @@ export class PluginService implements ClientHook { | |||
156 | logger('Loading scope %s', scope) | 142 | logger('Loading scope %s', scope) |
157 | 143 | ||
158 | try { | 144 | try { |
159 | await this.ensurePluginsAreBuilt() | ||
160 | |||
161 | if (!isReload) this.loadedScopes.push(scope) | 145 | if (!isReload) this.loadedScopes.push(scope) |
162 | 146 | ||
163 | const toLoad = this.scopes[ scope ] | 147 | const toLoad = this.scopes[ scope ] |