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