diff options
Diffstat (limited to 'client/src/app/core/plugins/plugin.service.ts')
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 90ebe5669..5d180e5a0 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -36,6 +36,7 @@ export class PluginService implements ClientHook { | |||
36 | private scopes: { [ scopeName: string ]: PluginInfo[] } = {} | 36 | private scopes: { [ scopeName: string ]: PluginInfo[] } = {} |
37 | private loadedScripts: { [ script: string ]: boolean } = {} | 37 | private loadedScripts: { [ script: string ]: boolean } = {} |
38 | private loadedScopes: PluginClientScope[] = [] | 38 | private loadedScopes: PluginClientScope[] = [] |
39 | private loadingScopes: { [id in PluginClientScope]?: boolean } = {} | ||
39 | 40 | ||
40 | private hooks: { [ name: string ]: HookStructValue[] } = {} | 41 | private hooks: { [ name: string ]: HookStructValue[] } = {} |
41 | 42 | ||
@@ -63,6 +64,8 @@ export class PluginService implements ClientHook { | |||
63 | } | 64 | } |
64 | 65 | ||
65 | ensurePluginsAreLoaded (scope: PluginClientScope) { | 66 | ensurePluginsAreLoaded (scope: PluginClientScope) { |
67 | this.loadPluginsByScope(scope) | ||
68 | |||
66 | return this.pluginsLoaded[scope].asObservable() | 69 | return this.pluginsLoaded[scope].asObservable() |
67 | .pipe(first(), shareReplay()) | 70 | .pipe(first(), shareReplay()) |
68 | .toPromise() | 71 | .toPromise() |
@@ -104,6 +107,11 @@ export class PluginService implements ClientHook { | |||
104 | } | 107 | } |
105 | 108 | ||
106 | async loadPluginsByScope (scope: PluginClientScope, isReload = false) { | 109 | async loadPluginsByScope (scope: PluginClientScope, isReload = false) { |
110 | if (this.loadingScopes[scope]) return | ||
111 | if (!isReload && this.loadedScopes.includes(scope)) return | ||
112 | |||
113 | this.loadingScopes[scope] = true | ||
114 | |||
107 | try { | 115 | try { |
108 | await this.ensurePluginsAreBuilt() | 116 | await this.ensurePluginsAreBuilt() |
109 | 117 | ||
@@ -111,6 +119,7 @@ export class PluginService implements ClientHook { | |||
111 | 119 | ||
112 | const toLoad = this.scopes[ scope ] | 120 | const toLoad = this.scopes[ scope ] |
113 | if (!Array.isArray(toLoad)) { | 121 | if (!Array.isArray(toLoad)) { |
122 | this.loadingScopes[scope] = false | ||
114 | this.pluginsLoaded[scope].next(true) | 123 | this.pluginsLoaded[scope].next(true) |
115 | 124 | ||
116 | return | 125 | return |
@@ -130,6 +139,7 @@ export class PluginService implements ClientHook { | |||
130 | await Promise.all(promises) | 139 | await Promise.all(promises) |
131 | 140 | ||
132 | this.pluginsLoaded[scope].next(true) | 141 | this.pluginsLoaded[scope].next(true) |
142 | this.loadingScopes[scope] = false | ||
133 | } catch (err) { | 143 | } catch (err) { |
134 | console.error('Cannot load plugins by scope %s.', scope, err) | 144 | console.error('Cannot load plugins by scope %s.', scope, err) |
135 | } | 145 | } |