From eab150cd3363897d482a2becde9e3f604b4b40b9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Dec 2024 13:59:27 +0100 Subject: [PATCH] Load themes as sound as possible --- client/src/app/app.component.ts | 3 --- client/src/app/core/plugins/plugin.service.ts | 2 +- client/src/main.ts | 20 +++++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index a83f2e2e2..605c629fd 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -11,7 +11,6 @@ import { ScreenService, ScrollService, ServerService, - ThemeService, User, UserLocalStorageService } from '@app/core' @@ -93,7 +92,6 @@ export class AppComponent implements OnInit, AfterViewInit { private domSanitizer: DomSanitizer, private screenService: ScreenService, private hotkeysService: HotkeysService, - private themeService: ThemeService, private hooks: HooksService, private location: PlatformLocation, private modalService: NgbModal, @@ -115,7 +113,6 @@ export class AppComponent implements OnInit, AfterViewInit { this.serverConfig = this.serverService.getHTMLConfig() this.hooks.runAction('action:application.init', 'common') - this.themeService.initialize() this.authService.loadClientCredentials() diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 43f10e02e..348f6c344 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -81,7 +81,7 @@ export class PluginService implements ClientHook { initializePlugins () { this.pluginsManager.loadPluginsList(this.server.getHTMLConfig()) - this.pluginsManager.ensurePluginsAreLoaded('common') + return this.pluginsManager.ensurePluginsAreLoaded('common') } initializeCustomModal (customModal: CustomModalComponent) { diff --git a/client/src/main.ts b/client/src/main.ts index 842ed53d6..8867bc6af 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -11,7 +11,7 @@ import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap' import { LoadingBarModule } from '@ngx-loading-bar/core' import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client' import { ToastModule } from 'primeng/toast' -import { tap } from 'rxjs/operators' +import { switchMap } from 'rxjs/operators' import { AppComponent } from './app/app.component' import routes from './app/app.routes' import { @@ -20,6 +20,7 @@ import { PreloadSelectedModulesList, RedirectService, ServerService, + ThemeService, getCoreProviders } from './app/core' import { getMainProviders } from './app/shared/shared-main/main-providers' @@ -28,17 +29,24 @@ import { logger } from './root-helpers' registerLocaleData(localeOc, 'oc') -export function loadConfigFactory (server: ServerService, pluginService: PluginService, redirectService: RedirectService) { +export function loadConfigFactory ( + server: ServerService, + pluginService: PluginService, + themeService: ThemeService, + redirectService: RedirectService +) { const initializeServices = () => { redirectService.init() - pluginService.initializePlugins() + themeService.initialize() + + return pluginService.initializePlugins() } return () => { const result = server.loadHTMLConfig() - if (result) return result.pipe(tap(() => initializeServices())) + if (result) return result.pipe(switchMap(() => initializeServices())) - initializeServices() + return initializeServices() } } @@ -90,7 +98,7 @@ const bootstrap = () => bootstrapApplication(AppComponent, { { provide: APP_INITIALIZER, useFactory: loadConfigFactory, - deps: [ ServerService, PluginService, RedirectService ], + deps: [ ServerService, PluginService, ThemeService, RedirectService ], multi: true } ]