PeerTube/client/src/app/app.module.ts

93 lines
3.1 KiB
TypeScript
Raw Normal View History

2020-06-23 14:10:17 +02:00
import 'focus-visible'
2021-06-04 14:39:47 +02:00
import { tap } from 'rxjs/operators'
2021-01-18 11:16:37 +01:00
import { environment } from 'src/environments/environment'
2020-06-23 14:10:17 +02:00
import { APP_BASE_HREF, registerLocaleData } from '@angular/common'
2021-06-04 11:46:17 +02:00
import { APP_INITIALIZER, NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
2021-01-18 11:16:37 +01:00
import { ServiceWorkerModule } from '@angular/service-worker'
2020-06-23 14:10:17 +02:00
import localeOc from '@app/helpers/locales/oc'
import { AppRoutingModule } from './app-routing.module'
import { AppComponent } from './app.component'
2021-06-04 14:39:47 +02:00
import { CoreModule, PluginService, ServerService } from './core'
2020-06-24 15:29:08 +02:00
import { EmptyComponent } from './empty.component'
2020-05-29 16:16:24 +02:00
import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header'
2020-06-23 14:49:20 +02:00
import { HighlightPipe } from './header/highlight.pipe'
2021-01-18 11:16:37 +01:00
import { LanguageChooserComponent, MenuComponent, NotificationComponent } from './menu'
2020-06-23 14:10:17 +02:00
import { ConfirmComponent } from './modal/confirm.component'
import { CustomModalComponent } from './modal/custom-modal.component'
import { InstanceConfigWarningModalComponent } from './modal/instance-config-warning-modal.component'
import { QuickSettingsModalComponent } from './modal/quick-settings-modal.component'
import { AdminWelcomeModalComponent } from './modal/admin-welcome-modal.component'
import { AccountSetupWarningModalComponent } from './modal/account-setup-warning-modal.component'
2021-05-14 16:12:45 +02:00
import { SharedActorImageModule } from './shared/shared-actor-image/shared-actor-image.module'
2020-06-23 14:10:17 +02:00
import { SharedFormModule } from './shared/shared-forms'
import { SharedGlobalIconModule } from './shared/shared-icons'
import { SharedInstanceModule } from './shared/shared-instance'
import { SharedMainModule } from './shared/shared-main'
import { SharedUserInterfaceSettingsModule } from './shared/shared-user-settings'
registerLocaleData(localeOc, 'oc')
2016-11-20 17:18:15 +01:00
2021-06-04 14:39:47 +02:00
export function loadConfigFactory (server: ServerService, pluginService: PluginService) {
return () => {
const result = server.loadHTMLConfig()
if (result) return result.pipe(tap(() => pluginService.initializePlugins()))
return pluginService.initializePlugins()
}
2021-06-04 11:46:17 +02:00
}
2016-09-06 22:40:57 +02:00
@NgModule({
bootstrap: [ AppComponent ],
2020-06-23 14:10:17 +02:00
2016-09-06 22:40:57 +02:00
declarations: [
2017-12-01 09:20:19 +01:00
AppComponent,
2020-06-24 15:29:08 +02:00
EmptyComponent,
2017-12-01 09:20:19 +01:00
MenuComponent,
2018-06-28 13:59:48 +02:00
LanguageChooserComponent,
QuickSettingsModalComponent,
NotificationComponent,
2019-08-28 14:40:06 +02:00
HeaderComponent,
2020-01-20 15:12:51 +01:00
SearchTypeaheadComponent,
SuggestionComponent,
2020-06-23 14:49:20 +02:00
HighlightPipe,
2019-08-28 14:40:06 +02:00
AccountSetupWarningModalComponent,
CustomModalComponent,
AdminWelcomeModalComponent,
2020-06-23 14:10:17 +02:00
InstanceConfigWarningModalComponent,
ConfirmComponent
2016-09-06 22:40:57 +02:00
],
2020-06-23 14:10:17 +02:00
2016-11-20 17:18:15 +01:00
imports: [
2016-09-06 22:40:57 +02:00
BrowserModule,
2021-01-18 11:16:37 +01:00
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
2016-09-09 22:23:41 +02:00
2016-11-20 17:18:15 +01:00
CoreModule,
2020-06-23 14:10:17 +02:00
SharedMainModule,
SharedFormModule,
SharedUserInterfaceSettingsModule,
SharedGlobalIconModule,
SharedInstanceModule,
2021-04-28 11:49:34 +02:00
SharedActorImageModule,
2016-11-20 17:18:15 +01:00
2018-05-31 14:43:48 +02:00
AppRoutingModule // Put it after all the module because it has the 404 route
2016-09-06 22:40:57 +02:00
],
2020-02-07 15:51:19 +01:00
2018-05-31 18:12:15 +02:00
providers: [
{
provide: APP_BASE_HREF,
useValue: '/'
2021-06-04 11:46:17 +02:00
},
{
provide: APP_INITIALIZER,
useFactory: loadConfigFactory,
2021-06-04 14:39:47 +02:00
deps: [ ServerService, PluginService ],
2021-06-04 11:46:17 +02:00
multi: true
2021-06-04 14:39:47 +02:00
}
2018-05-31 18:12:15 +02:00
]
2016-09-06 22:40:57 +02:00
})
2017-12-11 17:36:46 +01:00
export class AppModule {}