mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 05:53:03 +00:00
[DURACOM-288] Refactoring configuration to transfer state
This commit is contained in:
@@ -21,7 +21,10 @@ import { LocaleService } from '../../app/core/locale/locale.service';
|
||||
import { HeadTagService } from '../../app/core/metadata/head-tag.service';
|
||||
import { CorrelationIdService } from '../../app/correlation-id/correlation-id.service';
|
||||
import { InitService } from '../../app/init.service';
|
||||
import { isNotEmpty } from '../../app/shared/empty.util';
|
||||
import {
|
||||
isEmpty,
|
||||
isNotEmpty,
|
||||
} from '../../app/shared/empty.util';
|
||||
import { MenuService } from '../../app/shared/menu/menu.service';
|
||||
import { ThemeService } from '../../app/shared/theme-support/theme.service';
|
||||
import { Angulartics2DSpace } from '../../app/statistics/angulartics/dspace-provider';
|
||||
@@ -30,6 +33,7 @@ import {
|
||||
APP_CONFIG_STATE,
|
||||
AppConfig,
|
||||
} from '../../config/app-config.interface';
|
||||
import { BuildConfig } from '../../config/build-config.interface';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
/**
|
||||
@@ -41,7 +45,7 @@ export class ServerInitService extends InitService {
|
||||
protected store: Store<AppState>,
|
||||
protected correlationIdService: CorrelationIdService,
|
||||
protected transferState: TransferState,
|
||||
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||
@Inject(APP_CONFIG) protected appConfig: BuildConfig,
|
||||
protected translate: TranslateService,
|
||||
protected localeService: LocaleService,
|
||||
protected angulartics2DSpace: Angulartics2DSpace,
|
||||
@@ -68,9 +72,7 @@ export class ServerInitService extends InitService {
|
||||
return async () => {
|
||||
this.checkAuthenticationToken();
|
||||
this.saveAppConfigForCSR();
|
||||
if (this.appConfig.ui.transferState) {
|
||||
this.saveAppState();
|
||||
}
|
||||
this.saveAppState();
|
||||
this.initCorrelationId();
|
||||
|
||||
this.checkEnvironment();
|
||||
@@ -92,14 +94,16 @@ export class ServerInitService extends InitService {
|
||||
* @private
|
||||
*/
|
||||
private saveAppState() {
|
||||
this.transferState.onSerialize(InitService.NGRX_STATE, () => {
|
||||
let state;
|
||||
this.store.pipe(take(1)).subscribe((saveState: any) => {
|
||||
state = saveState;
|
||||
});
|
||||
if (this.appConfig.ssr.transferState && (isEmpty(this.appConfig.rest.ssrBaseUrl) || this.appConfig.ssr.replaceRestUrl)) {
|
||||
this.transferState.onSerialize(InitService.NGRX_STATE, () => {
|
||||
let state;
|
||||
this.store.pipe(take(1)).subscribe((saveState: any) => {
|
||||
state = saveState;
|
||||
});
|
||||
|
||||
return state;
|
||||
});
|
||||
return state;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private saveAppConfigForCSR(): void {
|
||||
|
Reference in New Issue
Block a user