2019-11-12 09:54:21 +00:00
|
|
|
import { NgModule, APP_INITIALIZER, Type } from '@angular/core';
|
|
|
|
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
|
|
|
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
|
2019-09-18 06:02:21 +00:00
|
|
|
|
2019-09-19 05:15:43 +00:00
|
|
|
import { RESOLVERS } from './resolvers';
|
2019-09-19 01:40:16 +00:00
|
|
|
import { SERVICES } from './services';
|
|
|
|
import { AppService } from './services/app.service';
|
2019-11-12 09:54:21 +00:00
|
|
|
|
2019-11-11 06:53:39 +00:00
|
|
|
import { environment } from '../environments/environment';
|
2019-11-12 09:54:21 +00:00
|
|
|
import { BrowserNativeService } from '@ucap-webmessenger/native-browser';
|
|
|
|
import { ElectronNativeService } from '@ucap-webmessenger/native-electron';
|
2020-01-06 08:05:36 +00:00
|
|
|
import { MatPaginatorIntl, MatPaginatorModule } from '@angular/material';
|
|
|
|
import { PaginatorIntlService } from '@ucap-webmessenger/ui';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2019-09-19 01:40:16 +00:00
|
|
|
|
2019-11-12 09:54:21 +00:00
|
|
|
export function initializeApp(
|
|
|
|
appService: AppService,
|
|
|
|
nativeService: NativeService
|
|
|
|
) {
|
2019-09-19 01:40:16 +00:00
|
|
|
return (): Promise<any> => {
|
|
|
|
return appService.postInit();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-18 06:02:21 +00:00
|
|
|
@NgModule({
|
2020-01-06 08:05:36 +00:00
|
|
|
imports: [MatPaginatorModule],
|
2019-09-18 06:02:21 +00:00
|
|
|
exports: [],
|
|
|
|
providers: [
|
2019-11-11 06:53:39 +00:00
|
|
|
{
|
|
|
|
provide: UCAP_NATIVE_SERVICE,
|
2019-11-12 09:54:21 +00:00
|
|
|
// useFactory: nativeServiceFactory,
|
|
|
|
useClass:
|
|
|
|
'browser' === environment.runtime
|
|
|
|
? BrowserNativeService
|
|
|
|
: ElectronNativeService,
|
2019-12-12 08:15:09 +00:00
|
|
|
deps: [HttpClient]
|
2019-11-11 06:53:39 +00:00
|
|
|
},
|
2020-01-06 08:05:36 +00:00
|
|
|
{
|
|
|
|
provide: MatPaginatorIntl,
|
|
|
|
useClass: PaginatorIntlService
|
|
|
|
},
|
2019-11-12 09:54:21 +00:00
|
|
|
...SERVICES,
|
|
|
|
...RESOLVERS,
|
2019-09-19 01:40:16 +00:00
|
|
|
{
|
|
|
|
provide: APP_INITIALIZER,
|
|
|
|
useFactory: initializeApp,
|
2019-11-11 09:09:47 +00:00
|
|
|
deps: [AppService, UCAP_NATIVE_SERVICE],
|
2019-12-12 08:15:09 +00:00
|
|
|
multi: true
|
|
|
|
}
|
|
|
|
]
|
2019-09-18 06:02:21 +00:00
|
|
|
})
|
|
|
|
export class AppProviderModule {}
|