From 62311282880cafd47b2460548cc322e2106c0736 Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Thu, 13 Aug 2026 08:56:25 +0400 Subject: [PATCH] fix: static-page loadByKey/loadByPath had no error handler, infinite spinner on failure resolveByKey/resolveByRoute subscribed with only a next callback - a resolver failure left loading=true forever with no error branch to recover from. Added an error signal, error subscribe handler, and a distinct error state UI (separate from the existing 404 not-found state) with a way back home. Co-Authored-By: Claude Sonnet 5 --- .../static-page/static-page.component.html | 8 ++++++++ .../static-page/static-page.component.ts | 20 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/app/pages/static-page/static-page.component.html b/src/app/pages/static-page/static-page.component.html index 33d3ac7..95d0bf0 100644 --- a/src/app/pages/static-page/static-page.component.html +++ b/src/app/pages/static-page/static-page.component.html @@ -6,6 +6,14 @@ + } @else if (error()) { +
+ +
+ {{ 'staticPages.backHome' | translate }} +
+
+
} @else if (notFound()) {
diff --git a/src/app/pages/static-page/static-page.component.ts b/src/app/pages/static-page/static-page.component.ts index 247855b..47698d2 100644 --- a/src/app/pages/static-page/static-page.component.ts +++ b/src/app/pages/static-page/static-page.component.ts @@ -29,6 +29,7 @@ export class StaticPageComponent { readonly loading = signal(true); readonly notFound = signal(false); + readonly error = signal(false); readonly title = signal(''); readonly homeRoute = signal(''); readonly dir = signal<'ltr' | 'rtl'>('ltr'); @@ -76,21 +77,32 @@ export class StaticPageComponent { private loadByKey(key: string): void { this.loading.set(true); this.notFound.set(false); + this.error.set(false); - this.staticPageResolver.resolveByKey(key, this.languageService.currentLanguage()).subscribe(page => { - this.applyPage(page?.title ?? '', page?.html ?? '', !page); + this.staticPageResolver.resolveByKey(key, this.languageService.currentLanguage()).subscribe({ + next: page => this.applyPage(page?.title ?? '', page?.html ?? '', !page), + error: () => this.applyError() }); } private loadByPath(path: string): void { this.loading.set(true); this.notFound.set(false); + this.error.set(false); - this.staticPageResolver.resolveByRoute(path, this.languageService.currentLanguage()).subscribe(page => { - this.applyPage(page?.title ?? '', page?.html ?? '', !page); + this.staticPageResolver.resolveByRoute(path, this.languageService.currentLanguage()).subscribe({ + next: page => this.applyPage(page?.title ?? '', page?.html ?? '', !page), + error: () => this.applyError() }); } + private applyError(): void { + this.title.set(''); + this.safeHtml.set(this.sanitizer.bypassSecurityTrustHtml('')); + this.error.set(true); + this.loading.set(false); + } + private applyPage(title: string, html: string, notFound: boolean): void { if (notFound) { this.title.set('');