From d15fb0c265b939709dabf1f6eca6b9e7a0fd03bb Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Mon, 15 Jul 2019 13:01:41 +0200 Subject: [PATCH] Fix loading in New state. --- .../content/pages/content/content-page.component.ts | 2 ++ src/Squidex/app/shared/state/contents.state.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Squidex/app/features/content/pages/content/content-page.component.ts b/src/Squidex/app/features/content/pages/content/content-page.component.ts index 8eee695c3..02d6ada50 100644 --- a/src/Squidex/app/features/content/pages/content/content-page.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-page.component.ts @@ -78,6 +78,8 @@ export class ContentPageComponent extends ResourceOwner implements CanComponentD } public ngOnInit() { + this.contentsState.loadIfNotLoaded(); + this.own( this.languagesState.languages .subscribe(languages => { diff --git a/src/Squidex/app/shared/state/contents.state.ts b/src/Squidex/app/shared/state/contents.state.ts index 017d5dc94..74ab25153 100644 --- a/src/Squidex/app/shared/state/contents.state.ts +++ b/src/Squidex/app/shared/state/contents.state.ts @@ -6,7 +6,7 @@ */ 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 { @@ -124,6 +124,14 @@ export abstract class ContentsStateBase extends State { return this.loadInternal(isReload); } + public loadIfNotLoaded(): Observable { + if (this.snapshot.isLoaded) { + return empty(); + } + + return this.loadInternal(false); + } + private loadInternal(isReload = false) { return this.loadInternalCore(isReload).pipe(shareSubscribed(this.dialogs)); }