mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-14 00:09:35 -06:00
Simplfy this too
This commit is contained in:
@@ -1618,7 +1618,9 @@ describe('DocumentDetailComponent', () => {
|
|||||||
expect(selectSpy).toHaveBeenCalledWith(99)
|
expect(selectSpy).toHaveBeenCalledWith(99)
|
||||||
|
|
||||||
component.selectedVersionId = 3
|
component.selectedVersionId = 3
|
||||||
deleteSpy.mockReturnValueOnce(of({ result: 'ok' }))
|
deleteSpy.mockReturnValueOnce(
|
||||||
|
of({ result: 'ok', current_version_id: null })
|
||||||
|
)
|
||||||
versionsSpy.mockReturnValueOnce(
|
versionsSpy.mockReturnValueOnce(
|
||||||
of({
|
of({
|
||||||
id: doc.id,
|
id: doc.id,
|
||||||
@@ -1629,7 +1631,7 @@ describe('DocumentDetailComponent', () => {
|
|||||||
} as Document)
|
} as Document)
|
||||||
)
|
)
|
||||||
component.deleteVersion(3)
|
component.deleteVersion(3)
|
||||||
expect(selectSpy).toHaveBeenCalledWith(7)
|
expect(selectSpy).toHaveBeenCalledWith(component.documentId)
|
||||||
|
|
||||||
deleteSpy.mockReturnValueOnce(throwError(() => new Error('nope')))
|
deleteSpy.mockReturnValueOnce(throwError(() => new Error('nope')))
|
||||||
component.deleteVersion(10)
|
component.deleteVersion(10)
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ export class DocumentDetailComponent
|
|||||||
.pipe(
|
.pipe(
|
||||||
catchError((error) => {
|
catchError((error) => {
|
||||||
if (error?.status === 404) {
|
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(
|
return this.documentsService.getRootId(documentId).pipe(
|
||||||
map((result) => {
|
map((result) => {
|
||||||
const rootId = result?.root_id
|
const rootId = result?.root_id
|
||||||
@@ -835,10 +836,7 @@ export class DocumentDetailComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wasSelected) {
|
if (wasSelected) {
|
||||||
const fallbackId =
|
const fallbackId = result?.current_version_id ?? this.documentId
|
||||||
result?.current_version_id ??
|
|
||||||
doc?.versions?.[0]?.id ??
|
|
||||||
this.documentId
|
|
||||||
this.selectVersion(fallbackId)
|
this.selectVersion(fallbackId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user