mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-11 10:00:48 -05:00
Correct runtime issue(s) with saveEditNext
This commit is contained in:
parent
9bc48fed73
commit
66b9a99e71
@ -124,14 +124,18 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen
|
|||||||
|
|
||||||
this.route.paramMap.pipe(switchMap(paramMap => {
|
this.route.paramMap.pipe(switchMap(paramMap => {
|
||||||
const documentId = +paramMap.get('id')
|
const documentId = +paramMap.get('id')
|
||||||
return this.documentsService.get(documentId).pipe(map(doc => ({doc, documentId})))
|
return this.documentsService.get(documentId)
|
||||||
})).pipe(switchMap(({doc, documentId}) => {
|
})).pipe(switchMap((doc) => {
|
||||||
this.previewUrl = this.documentsService.getPreviewUrl(documentId)
|
this.documentId = doc.id
|
||||||
this.downloadUrl = this.documentsService.getDownloadUrl(documentId)
|
this.previewUrl = this.documentsService.getPreviewUrl(this.documentId)
|
||||||
this.downloadOriginalUrl = this.documentsService.getDownloadUrl(documentId, true)
|
this.downloadUrl = this.documentsService.getDownloadUrl(this.documentId)
|
||||||
|
this.downloadOriginalUrl = this.documentsService.getDownloadUrl(this.documentId, true)
|
||||||
this.suggestions = null
|
this.suggestions = null
|
||||||
if (this.openDocumentService.getOpenDocument(documentId)) {
|
if (this.openDocumentService.getOpenDocument(this.documentId)) {
|
||||||
this.updateComponent(this.openDocumentService.getOpenDocument(documentId))
|
this.updateComponent(this.openDocumentService.getOpenDocument(this.documentId))
|
||||||
|
} else {
|
||||||
|
this.openDocumentService.openDocument(doc)
|
||||||
|
this.updateComponent(doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize dirtyCheck
|
// Initialize dirtyCheck
|
||||||
@ -147,17 +151,11 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen
|
|||||||
|
|
||||||
this.isDirty$ = dirtyCheck(this.documentForm, this.store.asObservable())
|
this.isDirty$ = dirtyCheck(this.documentForm, this.store.asObservable())
|
||||||
|
|
||||||
return this.isDirty$.pipe(map(dirty => ({doc, documentId, dirty})))
|
return this.isDirty$.pipe(map(dirty => ({doc, dirty})))
|
||||||
}))
|
}))
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
.subscribe(({doc, documentId, dirty}) => {
|
.subscribe(({doc, dirty}) => {
|
||||||
this.documentId = documentId
|
this.openDocumentService.setDirty(doc.id, dirty)
|
||||||
this.openDocumentService.setDirty(documentId, dirty)
|
|
||||||
|
|
||||||
if (!this.openDocumentService.getOpenDocument(documentId)) {
|
|
||||||
this.openDocumentService.openDocument(doc)
|
|
||||||
this.updateComponent(doc)
|
|
||||||
}
|
|
||||||
}, error => {this.router.navigate(['404'])})
|
}, error => {this.router.navigate(['404'])})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,13 +235,13 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen
|
|||||||
this.documentsService.update(this.document).pipe(switchMap(updateResult => {
|
this.documentsService.update(this.document).pipe(switchMap(updateResult => {
|
||||||
return this.documentListViewService.getNext(this.documentId).pipe(map(nextDocId => ({nextDocId, updateResult})))
|
return this.documentListViewService.getNext(this.documentId).pipe(map(nextDocId => ({nextDocId, updateResult})))
|
||||||
})).pipe(switchMap(({nextDocId, updateResult}) => {
|
})).pipe(switchMap(({nextDocId, updateResult}) => {
|
||||||
if (nextDocId) return this.openDocumentService.closeDocument(this.document, true).pipe(map(closeResult => ({updateResult, nextDocId, closeResult})))
|
if (nextDocId && updateResult) return this.openDocumentService.closeDocument(this.document).pipe(map(closeResult => ({updateResult, nextDocId, closeResult})))
|
||||||
}))
|
}))
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
.pipe(first())
|
||||||
.subscribe(({updateResult, nextDocId, closeResult}) => {
|
.subscribe(({updateResult, nextDocId, closeResult}) => {
|
||||||
this.error = null
|
this.error = null
|
||||||
this.networkActive = false
|
this.networkActive = false
|
||||||
if (closeResult) {
|
if (closeResult && updateResult && nextDocId) {
|
||||||
this.router.navigate(['documents', nextDocId])
|
this.router.navigate(['documents', nextDocId])
|
||||||
this.titleInput?.focus()
|
this.titleInput?.focus()
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@ export class OpenDocumentsService {
|
|||||||
else this.dirtyDocuments.delete(documentId)
|
else this.dirtyDocuments.delete(documentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDocument(doc: PaperlessDocument, force: boolean = false): Observable<boolean> {
|
closeDocument(doc: PaperlessDocument): Observable<boolean> {
|
||||||
let index = this.openDocuments.findIndex(d => d.id == doc.id)
|
let index = this.openDocuments.findIndex(d => d.id == doc.id)
|
||||||
if (index == -1) return of(true);
|
if (index == -1) return of(true);
|
||||||
if (force || !this.dirtyDocuments.has(doc.id)) {
|
if (!this.dirtyDocuments.has(doc.id)) {
|
||||||
this.openDocuments.splice(index, 1)
|
this.openDocuments.splice(index, 1)
|
||||||
this.save()
|
this.save()
|
||||||
return of(true)
|
return of(true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user