mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-14 01:21:14 -06:00
Fix: fix auto-close after giving a document away
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { DatePipe } from '@angular/common'
|
||||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
|
||||
import {
|
||||
HttpErrorResponse,
|
||||
provideHttpClient,
|
||||
withInterceptorsFromDi,
|
||||
} from '@angular/common/http'
|
||||
import {
|
||||
HttpTestingController,
|
||||
provideHttpClientTesting,
|
||||
@@ -503,7 +507,7 @@ describe('DocumentDetailComponent', () => {
|
||||
const updateSpy = jest.spyOn(documentService, 'update')
|
||||
const toastSpy = jest.spyOn(toastService, 'showInfo')
|
||||
updateSpy.mockImplementation(() =>
|
||||
throwError(() => new Error('failed to save'))
|
||||
throwError(() => new HttpErrorResponse({ status: 403 }))
|
||||
)
|
||||
component.save(true)
|
||||
expect(updateSpy).toHaveBeenCalled()
|
||||
|
||||
@@ -824,11 +824,13 @@ export class DocumentDetailComponent
|
||||
},
|
||||
error: (error) => {
|
||||
this.networkActive = false
|
||||
if (!this.userCanEdit) {
|
||||
if (error.status === 403) {
|
||||
// e.g. document was 'given away'
|
||||
this.openDocumentService.setDirty(this.document, false)
|
||||
this.toastService.showInfo(
|
||||
$localize`Document "${this.document.title}" saved successfully.`
|
||||
)
|
||||
close && this.close()
|
||||
this.close()
|
||||
} else {
|
||||
this.error = error.error
|
||||
this.toastService.showError(
|
||||
|
||||
Reference in New Issue
Block a user