mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	Fix title subscription fires even after doc change
This commit is contained in:
		
							parent
							
								
									9ae20a6bec
								
							
						
					
					
						commit
						79e218d00a
					
				@ -85,6 +85,7 @@ export class DocumentDetailComponent
 | 
			
		||||
  store: BehaviorSubject<any>
 | 
			
		||||
  isDirty$: Observable<boolean>
 | 
			
		||||
  unsubscribeNotifier: Subject<any> = new Subject()
 | 
			
		||||
  docChangeNotifier: Subject<any> = new Subject()
 | 
			
		||||
 | 
			
		||||
  requiresPassword: boolean = false
 | 
			
		||||
  password: string
 | 
			
		||||
@ -117,18 +118,7 @@ export class DocumentDetailComponent
 | 
			
		||||
    private toastService: ToastService,
 | 
			
		||||
    private settings: SettingsService,
 | 
			
		||||
    private queryParamsService: QueryParamsService
 | 
			
		||||
  ) {
 | 
			
		||||
    this.titleSubject
 | 
			
		||||
      .pipe(
 | 
			
		||||
        debounceTime(1000),
 | 
			
		||||
        distinctUntilChanged(),
 | 
			
		||||
        takeUntil(this.unsubscribeNotifier)
 | 
			
		||||
      )
 | 
			
		||||
      .subscribe((titleValue) => {
 | 
			
		||||
        this.title = titleValue
 | 
			
		||||
        this.documentForm.patchValue({ title: titleValue })
 | 
			
		||||
      })
 | 
			
		||||
  }
 | 
			
		||||
  ) {}
 | 
			
		||||
 | 
			
		||||
  titleKeyUp(event) {
 | 
			
		||||
    this.titleSubject.next(event.target?.value)
 | 
			
		||||
@ -184,6 +174,7 @@ export class DocumentDetailComponent
 | 
			
		||||
      .pipe(
 | 
			
		||||
        switchMap((paramMap) => {
 | 
			
		||||
          const documentId = +paramMap.get('id')
 | 
			
		||||
          this.docChangeNotifier.next(documentId)
 | 
			
		||||
          return this.documentsService.get(documentId)
 | 
			
		||||
        })
 | 
			
		||||
      )
 | 
			
		||||
@ -208,6 +199,18 @@ export class DocumentDetailComponent
 | 
			
		||||
            this.updateComponent(doc)
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          this.titleSubject
 | 
			
		||||
            .pipe(
 | 
			
		||||
              debounceTime(1000),
 | 
			
		||||
              distinctUntilChanged(),
 | 
			
		||||
              takeUntil(this.docChangeNotifier),
 | 
			
		||||
              takeUntil(this.unsubscribeNotifier)
 | 
			
		||||
            )
 | 
			
		||||
            .subscribe((titleValue) => {
 | 
			
		||||
              this.title = titleValue
 | 
			
		||||
              this.documentForm.patchValue({ title: titleValue })
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
          this.ogDate = new Date(normalizeDateStr(doc.created.toString()))
 | 
			
		||||
 | 
			
		||||
          // Initialize dirtyCheck
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user