Load themes as sound as possible

pull/6784/head
Chocobozzz 2024-12-10 13:59:27 +01:00
parent b2aac08921
commit eab150cd33
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 15 additions and 10 deletions

View File

@ -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()

View File

@ -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) {

View File

@ -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
}
]