Fix: fix auto-close after giving a document away

This commit is contained in:
shamoon
2025-03-21 08:08:36 -07:00
parent 5d6cfa7349
commit c27e3c75cd
4 changed files with 49 additions and 6 deletions

View File

@@ -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()

View File

@@ -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(