From 8a7e26d2b6a16689b061b695a56aa0855e945aa5 Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Wed, 11 Sep 2024 12:26:28 +0200 Subject: [PATCH] =?UTF-8?q?Timeout=20nur=20f=C3=BCr=20/ai=20Calls,=20URL?= =?UTF-8?q?=20compare=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/interceptors/timeout.interceptor.ts | 38 +++++++++++-------- .../edit-business-listing.component.ts | 2 +- ...t-commercial-property-listing.component.ts | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/bizmatch/src/app/interceptors/timeout.interceptor.ts b/bizmatch/src/app/interceptors/timeout.interceptor.ts index ce0c3e5..afebe07 100644 --- a/bizmatch/src/app/interceptors/timeout.interceptor.ts +++ b/bizmatch/src/app/interceptors/timeout.interceptor.ts @@ -8,21 +8,27 @@ export class TimeoutInterceptor implements HttpInterceptor { constructor(@Optional() @Inject('TIMEOUT_DURATION') private timeoutDuration: number = 5000) {} intercept(req: HttpRequest, next: HttpHandler): Observable> { - return next.handle(req).pipe( - timeout(this.timeoutDuration), - catchError((error: any) => { - if (error instanceof TimeoutError) { - // Timeout error handling - return throwError( - () => - new HttpErrorResponse({ - error: 'Request timed out', - status: 408, // HTTP status code for Request Timeout - }), - ); - } - return throwError(() => error); - }), - ); + // Überprüfen, ob die URL mit '/ai' endet + if (req.url.endsWith('/ai')) { + return next.handle(req).pipe( + timeout(this.timeoutDuration), + catchError((error: any) => { + if (error instanceof TimeoutError) { + // Timeout error handling + return throwError( + () => + new HttpErrorResponse({ + error: 'Request timed out', + status: 408, // HTTP status code for Request Timeout + }), + ); + } + return throwError(() => error); + }), + ); + } + + // Für alle anderen URLs ohne Timeout fortfahren + return next.handle(req); } } diff --git a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts index 68cb1cd..b8f24ff 100644 --- a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts +++ b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.ts @@ -90,7 +90,7 @@ export class EditBusinessListingComponent { ) { this.router.events.subscribe(event => { if (event instanceof NavigationEnd) { - this.mode = event.url === '/createBusinessListing' ? 'create' : 'edit'; + this.mode = event.url.startsWith('/createBusinessListing') ? 'create' : 'edit'; } }); this.route.data.subscribe(async () => { diff --git a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts index 1051dba..f4c3d82 100644 --- a/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts +++ b/bizmatch/src/app/pages/subscription/edit-commercial-property-listing/edit-commercial-property-listing.component.ts @@ -132,7 +132,7 @@ export class EditCommercialPropertyListingComponent { // Abonniere Router-Events, um den aktiven Link zu ermitteln this.router.events.subscribe(event => { if (event instanceof NavigationEnd) { - this.mode = event.url === '/createCommercialPropertyListing' ? 'create' : 'edit'; + this.mode = event.url.startsWith('/createCommercialPropertyListing') ? 'create' : 'edit'; } }); this.route.data.subscribe(async () => {