]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app.module.ts
Client: move menu component in core module
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
1 import { ApplicationRef, NgModule } from '@angular/core';
2 import { BrowserModule } from '@angular/platform-browser';
3 import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
4
5 import { MetaModule, MetaConfig } from 'ng2-meta';
6
7 import { ENV_PROVIDERS } from './environment';
8 import { AppRoutingModule } from './app-routing.module';
9 import { AppComponent } from './app.component';
10 import { AppState } from './app.service';
11
12 import { AccountModule } from './account';
13 import { AdminModule } from './admin';
14 import { CoreModule } from './core';
15 import { LoginModule } from './login';
16 import { SharedModule } from './shared';
17 import { VideosModule } from './videos';
18
19 const metaConfig: MetaConfig = {
20 //Append a title suffix such as a site name to all titles
21 //Defaults to false
22 useTitleSuffix: true,
23 defaults: {
24 title: 'PeerTube'
25 }
26 };
27
28 // Application wide providers
29 const APP_PROVIDERS = [
30 AppState
31 ];
32
33 @NgModule({
34 bootstrap: [ AppComponent ],
35 declarations: [
36 AppComponent
37 ],
38 imports: [
39 BrowserModule,
40
41 CoreModule,
42 SharedModule,
43
44 AppRoutingModule,
45
46 MetaModule.forRoot(metaConfig),
47
48 AccountModule,
49 AdminModule,
50 CoreModule,
51 LoginModule,
52 SharedModule,
53 VideosModule
54 ],
55 providers: [ // expose our Services and Providers into Angular's dependency injection
56 ENV_PROVIDERS,
57 APP_PROVIDERS
58 ]
59 })
60 export class AppModule {
61 constructor(public appRef: ApplicationRef, public appState: AppState) {}
62 hmrOnInit(store) {
63 if (!store || !store.state) return;
64 console.log('HMR store', store);
65 this.appState._state = store.state;
66 this.appRef.tick();
67 delete store.state;
68 }
69 hmrOnDestroy(store) {
70 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
71 // recreate elements
72 const state = this.appState._state;
73 store.state = state;
74 store.disposeOldHosts = createNewHosts(cmpLocation);
75 // remove styles
76 removeNgStyles();
77 }
78 hmrAfterDestroy(store) {
79 // display new elements
80 store.disposeOldHosts();
81 delete store.disposeOldHosts;
82 }
83 }