]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Unify 404 logic fix-refactor-docform 10662/head
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sat, 23 Aug 2025 02:42:33 +0000 (19:42 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Sat, 23 Aug 2025 03:03:51 +0000 (20:03 -0700)
src-ui/src/app/components/document-detail/document-detail.component.ts

index 06775ed30639515db211efedb6028de7c2f5efdb..a7cda447d9ac5888e0209e1b7eaf2c86b8c03fff 100644 (file)
@@ -21,8 +21,9 @@ import { dirtyCheck, DirtyComponent } from '@ngneat/dirty-check-forms'
 import { PDFDocumentProxy, PdfViewerModule } from 'ng2-pdf-viewer'
 import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
 import { DeviceDetectorService } from 'ngx-device-detector'
-import { BehaviorSubject, Observable, Subject } from 'rxjs'
+import { BehaviorSubject, Observable, of, Subject } from 'rxjs'
 import {
+  catchError,
   debounceTime,
   distinctUntilChanged,
   filter,
@@ -406,7 +407,13 @@ export class DocumentDetailComponent
     this.thumbUrl = this.documentsService.getThumbUrl(documentId)
     this.documentsService
       .get(documentId)
-      .pipe(first())
+      .pipe(
+        catchError(() => {
+          // 404 is handled in the subscribe below
+          return of(null)
+        }),
+        first()
+      )
       .subscribe({
         next: (doc) => {
           if (!doc) {
@@ -452,10 +459,6 @@ export class DocumentDetailComponent
             })
           this.setupDirtyTracking(useDoc, doc)
         },
-        error: () =>
-          this.router.navigate(['404'], {
-            replaceUrl: true,
-          }),
       })
   }