diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-04 14:39:47 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-04 15:45:44 +0200 |
commit | fc21ef5c62d845576a916414468b3a57370a57b2 (patch) | |
tree | 818102bc909210870f9a28692361f7b5cbe219de /client/src/app/app.module.ts | |
parent | 2989628b7913383b39ac34c7db8666a21f8e5037 (diff) | |
download | PeerTube-fc21ef5c62d845576a916414468b3a57370a57b2.tar.gz PeerTube-fc21ef5c62d845576a916414468b3a57370a57b2.tar.zst PeerTube-fc21ef5c62d845576a916414468b3a57370a57b2.zip |
Speed up plugins loading
Diffstat (limited to 'client/src/app/app.module.ts')
-rw-r--r-- | client/src/app/app.module.ts | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index ea53818e1..dfdccbe69 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import 'focus-visible' | 1 | import 'focus-visible' |
2 | import { tap } from 'rxjs/operators' | ||
2 | import { environment } from 'src/environments/environment' | 3 | import { environment } from 'src/environments/environment' |
3 | import { APP_BASE_HREF, registerLocaleData } from '@angular/common' | 4 | import { APP_BASE_HREF, registerLocaleData } from '@angular/common' |
4 | import { APP_INITIALIZER, NgModule } from '@angular/core' | 5 | import { APP_INITIALIZER, NgModule } from '@angular/core' |
@@ -7,7 +8,7 @@ import { ServiceWorkerModule } from '@angular/service-worker' | |||
7 | import localeOc from '@app/helpers/locales/oc' | 8 | import localeOc from '@app/helpers/locales/oc' |
8 | import { AppRoutingModule } from './app-routing.module' | 9 | import { AppRoutingModule } from './app-routing.module' |
9 | import { AppComponent } from './app.component' | 10 | import { AppComponent } from './app.component' |
10 | import { CoreModule, ServerService } from './core' | 11 | import { CoreModule, PluginService, ServerService } from './core' |
11 | import { EmptyComponent } from './empty.component' | 12 | import { EmptyComponent } from './empty.component' |
12 | import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header' | 13 | import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header' |
13 | import { HighlightPipe } from './header/highlight.pipe' | 14 | import { HighlightPipe } from './header/highlight.pipe' |
@@ -26,8 +27,14 @@ import { SharedUserInterfaceSettingsModule } from './shared/shared-user-settings | |||
26 | 27 | ||
27 | registerLocaleData(localeOc, 'oc') | 28 | registerLocaleData(localeOc, 'oc') |
28 | 29 | ||
29 | export function loadConfigFactory (server: ServerService) { | 30 | export function loadConfigFactory (server: ServerService, pluginService: PluginService) { |
30 | return () => server.loadHTMLConfig() | 31 | return () => { |
32 | const result = server.loadHTMLConfig() | ||
33 | |||
34 | if (result) return result.pipe(tap(() => pluginService.initializePlugins())) | ||
35 | |||
36 | return pluginService.initializePlugins() | ||
37 | } | ||
31 | } | 38 | } |
32 | 39 | ||
33 | @NgModule({ | 40 | @NgModule({ |
@@ -75,9 +82,9 @@ export function loadConfigFactory (server: ServerService) { | |||
75 | { | 82 | { |
76 | provide: APP_INITIALIZER, | 83 | provide: APP_INITIALIZER, |
77 | useFactory: loadConfigFactory, | 84 | useFactory: loadConfigFactory, |
78 | deps: [ ServerService ], | 85 | deps: [ ServerService, PluginService ], |
79 | multi: true | 86 | multi: true |
80 | } | 87 | } |
81 | ] | 88 | ] |
82 | }) | 89 | }) |
83 | export class AppModule {} | 90 | export class AppModule {} |