Browse Source

Fix loading in New state.

pull/387/head
Sebastian Stehle 7 years ago
parent
commit
d15fb0c265
  1. 2
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  2. 10
      src/Squidex/app/shared/state/contents.state.ts

2
src/Squidex/app/features/content/pages/content/content-page.component.ts

@ -78,6 +78,8 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD
} }
public ngOnInit() { public ngOnInit() {
this.contentsState.loadIfNotLoaded();
this.own( this.own(
this.languagesState.languages this.languagesState.languages
.subscribe(languages => { .subscribe(languages => {

10
src/Squidex/app/shared/state/contents.state.ts

@ -6,7 +6,7 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { forkJoin, Observable, of } from 'rxjs'; import { forkJoin, Observable, of, empty } from 'rxjs';
import { catchError, switchMap, tap } from 'rxjs/operators'; import { catchError, switchMap, tap } from 'rxjs/operators';
import { import {
@ -124,6 +124,14 @@ export abstract class ContentsStateBase extends State<Snapshot> {
return this.loadInternal(isReload); return this.loadInternal(isReload);
} }
public loadIfNotLoaded(): Observable<any> {
if (this.snapshot.isLoaded) {
return empty();
}
return this.loadInternal(false);
}
private loadInternal(isReload = false) { private loadInternal(isReload = false) {
return this.loadInternalCore(isReload).pipe(shareSubscribed(this.dialogs)); return this.loadInternalCore(isReload).pipe(shareSubscribed(this.dialogs));
} }

Loading…
Cancel
Save