]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Manually dirty check title on doc change 979/head
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 17 May 2022 17:36:43 +0000 (10:36 -0700)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 17 May 2022 17:36:43 +0000 (10:36 -0700)
src-ui/src/app/components/document-detail/document-detail.component.ts

index 3d4289ad857822755211eaf4e9d746c23173f5df..f3515c974c312fb6644fc3cb7a45903c51f0956c 100644 (file)
@@ -172,6 +172,7 @@ export class DocumentDetailComponent
 
     this.route.paramMap
       .pipe(
+        takeUntil(this.unsubscribeNotifier),
         switchMap((paramMap) => {
           const documentId = +paramMap.get('id')
           this.docChangeNotifier.next(documentId)
@@ -206,9 +207,20 @@ export class DocumentDetailComponent
               takeUntil(this.docChangeNotifier),
               takeUntil(this.unsubscribeNotifier)
             )
-            .subscribe((titleValue) => {
-              this.title = titleValue
-              this.documentForm.patchValue({ title: titleValue })
+            .subscribe({
+              next: (titleValue) => {
+                this.title = titleValue
+                this.documentForm.patchValue({ title: titleValue })
+              },
+              complete: () => {
+                // doc changed so we manually check dirty in case title was changed
+                if (
+                  this.store.getValue().title !==
+                  this.documentForm.get('title').value
+                ) {
+                  this.openDocumentService.setDirty(doc.id, true)
+                }
+              },
             })
 
           this.ogDate = new Date(normalizeDateStr(doc.created.toString()))
@@ -238,7 +250,6 @@ export class DocumentDetailComponent
           return this.isDirty$.pipe(map((dirty) => ({ doc, dirty })))
         })
       )
-      .pipe(takeUntil(this.unsubscribeNotifier))
       .subscribe({
         next: ({ doc, dirty }) => {
           this.openDocumentService.setDirty(doc.id, dirty)