aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.module.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
commitdf98563e2104b82b119c00a3cd83cd0dc1242d25 (patch)
treea9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/app.module.ts
parent46757b477c1adb5f98060d15998a3852e18902a6 (diff)
downloadPeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/app.module.ts')
-rw-r--r--client/src/app/app.module.ts80
1 files changed, 40 insertions, 40 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 8a072eaac..d7c9f6548 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -1,29 +1,29 @@
1import { ApplicationRef, NgModule } from '@angular/core'; 1import { ApplicationRef, NgModule } from '@angular/core'
2import { BrowserModule } from '@angular/platform-browser'; 2import { BrowserModule } from '@angular/platform-browser'
3import { 3import {
4 removeNgStyles, 4 removeNgStyles,
5 createNewHosts, 5 createNewHosts,
6 createInputTransfer 6 createInputTransfer
7} from '@angularclass/hmr'; 7} from '@angularclass/hmr'
8 8
9import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@nglibs/meta'; 9import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@nglibs/meta'
10// TODO: remove, we need this to avoid error in ng2-smart-table 10// TODO: remove, we need this to avoid error in ng2-smart-table
11import 'rxjs/add/operator/toPromise'; 11import 'rxjs/add/operator/toPromise'
12import 'bootstrap-loader'; 12import 'bootstrap-loader'
13 13
14import { ENV_PROVIDERS } from './environment'; 14import { ENV_PROVIDERS } from './environment'
15import { AppRoutingModule } from './app-routing.module'; 15import { AppRoutingModule } from './app-routing.module'
16import { AppComponent } from './app.component'; 16import { AppComponent } from './app.component'
17import { AppState, InternalStateType } from './app.service'; 17import { AppState, InternalStateType } from './app.service'
18 18
19import { AccountModule } from './account'; 19import { AccountModule } from './account'
20import { CoreModule } from './core'; 20import { CoreModule } from './core'
21import { LoginModule } from './login'; 21import { LoginModule } from './login'
22import { SignupModule } from './signup'; 22import { SignupModule } from './signup'
23import { SharedModule } from './shared'; 23import { SharedModule } from './shared'
24import { VideosModule } from './videos'; 24import { VideosModule } from './videos'
25 25
26export function metaFactory(): MetaLoader { 26export function metaFactory (): MetaLoader {
27 return new MetaStaticLoader({ 27 return new MetaStaticLoader({
28 pageTitlePositioning: PageTitlePositioning.PrependPageTitle, 28 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
29 pageTitleSeparator: ' - ', 29 pageTitleSeparator: ' - ',
@@ -32,19 +32,19 @@ export function metaFactory(): MetaLoader {
32 title: 'PeerTube', 32 title: 'PeerTube',
33 description: 'PeerTube, a decentralized video streaming platform using P2P (BitTorrent) directly in the web browser' 33 description: 'PeerTube, a decentralized video streaming platform using P2P (BitTorrent) directly in the web browser'
34 } 34 }
35 }); 35 })
36} 36}
37 37
38type StoreType = { 38type StoreType = {
39 state: InternalStateType, 39 state: InternalStateType,
40 restoreInputValues: () => void, 40 restoreInputValues: () => void,
41 disposeOldHosts: () => void 41 disposeOldHosts: () => void
42}; 42}
43 43
44// Application wide providers 44// Application wide providers
45const APP_PROVIDERS = [ 45const APP_PROVIDERS = [
46 AppState 46 AppState
47]; 47]
48 48
49@NgModule({ 49@NgModule({
50 bootstrap: [ AppComponent ], 50 bootstrap: [ AppComponent ],
@@ -77,59 +77,59 @@ const APP_PROVIDERS = [
77 ] 77 ]
78}) 78})
79export class AppModule { 79export class AppModule {
80 constructor( 80 constructor (
81 public appRef: ApplicationRef, 81 public appRef: ApplicationRef,
82 public appState: AppState 82 public appState: AppState
83 ) {} 83 ) {}
84 84
85 public hmrOnInit(store: StoreType) { 85 public hmrOnInit (store: StoreType) {
86 if (!store || !store.state) { 86 if (!store || !store.state) {
87 return; 87 return
88 } 88 }
89 console.log('HMR store', JSON.stringify(store, null, 2)); 89 console.log('HMR store', JSON.stringify(store, null, 2))
90 /** 90 /**
91 * Set state 91 * Set state
92 */ 92 */
93 this.appState._state = store.state; 93 this.appState._state = store.state
94 /** 94 /**
95 * Set input values 95 * Set input values
96 */ 96 */
97 if ('restoreInputValues' in store) { 97 if ('restoreInputValues' in store) {
98 let restoreInputValues = store.restoreInputValues; 98 let restoreInputValues = store.restoreInputValues
99 setTimeout(restoreInputValues); 99 setTimeout(restoreInputValues)
100 } 100 }
101 101
102 this.appRef.tick(); 102 this.appRef.tick()
103 delete store.state; 103 delete store.state
104 delete store.restoreInputValues; 104 delete store.restoreInputValues
105 } 105 }
106 106
107 public hmrOnDestroy(store: StoreType) { 107 public hmrOnDestroy (store: StoreType) {
108 const cmpLocation = this.appRef.components.map((cmp) => cmp.location.nativeElement); 108 const cmpLocation = this.appRef.components.map((cmp) => cmp.location.nativeElement)
109 /** 109 /**
110 * Save state 110 * Save state
111 */ 111 */
112 const state = this.appState._state; 112 const state = this.appState._state
113 store.state = state; 113 store.state = state
114 /** 114 /**
115 * Recreate root elements 115 * Recreate root elements
116 */ 116 */
117 store.disposeOldHosts = createNewHosts(cmpLocation); 117 store.disposeOldHosts = createNewHosts(cmpLocation)
118 /** 118 /**
119 * Save input values 119 * Save input values
120 */ 120 */
121 store.restoreInputValues = createInputTransfer(); 121 store.restoreInputValues = createInputTransfer()
122 /** 122 /**
123 * Remove styles 123 * Remove styles
124 */ 124 */
125 removeNgStyles(); 125 removeNgStyles()
126 } 126 }
127 127
128 public hmrAfterDestroy(store: StoreType) { 128 public hmrAfterDestroy (store: StoreType) {
129 /** 129 /**
130 * Display new elements 130 * Display new elements
131 */ 131 */
132 store.disposeOldHosts(); 132 store.disposeOldHosts ()
133 delete store.disposeOldHosts; 133 delete store.disposeOldHosts
134 } 134 }
135} 135}