From addb369d325ec4ac3c183d56072d40f09288444e Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 11 Feb 2026 21:56:40 -0800 Subject: [PATCH] Simplfy this too --- .../document-detail/document-detail.component.spec.ts | 6 ++++-- .../components/document-detail/document-detail.component.ts | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 4cfdcdf38..6ba9eaef6 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -1618,7 +1618,9 @@ describe('DocumentDetailComponent', () => { expect(selectSpy).toHaveBeenCalledWith(99) component.selectedVersionId = 3 - deleteSpy.mockReturnValueOnce(of({ result: 'ok' })) + deleteSpy.mockReturnValueOnce( + of({ result: 'ok', current_version_id: null }) + ) versionsSpy.mockReturnValueOnce( of({ id: doc.id, @@ -1629,7 +1631,7 @@ describe('DocumentDetailComponent', () => { } as Document) ) component.deleteVersion(3) - expect(selectSpy).toHaveBeenCalledWith(7) + expect(selectSpy).toHaveBeenCalledWith(component.documentId) deleteSpy.mockReturnValueOnce(throwError(() => new Error('nope'))) component.deleteVersion(10) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index ab0c302d2..568072861 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -473,6 +473,7 @@ export class DocumentDetailComponent .pipe( catchError((error) => { if (error?.status === 404) { + // if not found, check if there's root document that exists and redirect if so return this.documentsService.getRootId(documentId).pipe( map((result) => { const rootId = result?.root_id @@ -835,10 +836,7 @@ export class DocumentDetailComponent } if (wasSelected) { - const fallbackId = - result?.current_version_id ?? - doc?.versions?.[0]?.id ?? - this.documentId + const fallbackId = result?.current_version_id ?? this.documentId this.selectVersion(fallbackId) } },