mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	update list view when documents are added
This commit is contained in:
		@@ -1,9 +1,11 @@
 | 
				
			|||||||
import { AfterViewInit, Component, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
 | 
					import { AfterViewInit, Component, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
 | 
				
			||||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
					import { ActivatedRoute, Router } from '@angular/router';
 | 
				
			||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
 | 
					import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
 | 
				
			||||||
 | 
					import { Subscription } from 'rxjs';
 | 
				
			||||||
import { PaperlessDocument } from 'src/app/data/paperless-document';
 | 
					import { PaperlessDocument } from 'src/app/data/paperless-document';
 | 
				
			||||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
 | 
					import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
 | 
				
			||||||
import { SortableDirective, SortEvent } from 'src/app/directives/sortable.directive';
 | 
					import { SortableDirective, SortEvent } from 'src/app/directives/sortable.directive';
 | 
				
			||||||
 | 
					import { ConsumerStatusService } from 'src/app/services/consumer-status.service';
 | 
				
			||||||
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
 | 
					import { DocumentListViewService } from 'src/app/services/document-list-view.service';
 | 
				
			||||||
import { DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service';
 | 
					import { DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service';
 | 
				
			||||||
import { SavedViewService } from 'src/app/services/rest/saved-view.service';
 | 
					import { SavedViewService } from 'src/app/services/rest/saved-view.service';
 | 
				
			||||||
@@ -16,7 +18,7 @@ import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-vi
 | 
				
			|||||||
  templateUrl: './document-list.component.html',
 | 
					  templateUrl: './document-list.component.html',
 | 
				
			||||||
  styleUrls: ['./document-list.component.scss']
 | 
					  styleUrls: ['./document-list.component.scss']
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class DocumentListComponent implements OnInit {
 | 
					export class DocumentListComponent implements OnInit, OnDestroy {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    public list: DocumentListViewService,
 | 
					    public list: DocumentListViewService,
 | 
				
			||||||
@@ -24,7 +26,9 @@ export class DocumentListComponent implements OnInit {
 | 
				
			|||||||
    public route: ActivatedRoute,
 | 
					    public route: ActivatedRoute,
 | 
				
			||||||
    private router: Router,
 | 
					    private router: Router,
 | 
				
			||||||
    private toastService: ToastService,
 | 
					    private toastService: ToastService,
 | 
				
			||||||
    private modalService: NgbModal) { }
 | 
					    private modalService: NgbModal,
 | 
				
			||||||
 | 
					    private consumerStatusService: ConsumerStatusService
 | 
				
			||||||
 | 
					  ) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @ViewChild("filterEditor")
 | 
					  @ViewChild("filterEditor")
 | 
				
			||||||
  private filterEditor: FilterEditorComponent
 | 
					  private filterEditor: FilterEditorComponent
 | 
				
			||||||
@@ -35,6 +39,8 @@ export class DocumentListComponent implements OnInit {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  filterRulesModified: boolean = false
 | 
					  filterRulesModified: boolean = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  private consumptionFinishedSubscription: Subscription
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  get isFiltered() {
 | 
					  get isFiltered() {
 | 
				
			||||||
    return this.list.filterRules?.length > 0
 | 
					    return this.list.filterRules?.length > 0
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -63,6 +69,9 @@ export class DocumentListComponent implements OnInit {
 | 
				
			|||||||
    if (localStorage.getItem('document-list:displayMode') != null) {
 | 
					    if (localStorage.getItem('document-list:displayMode') != null) {
 | 
				
			||||||
      this.displayMode = localStorage.getItem('document-list:displayMode')
 | 
					      this.displayMode = localStorage.getItem('document-list:displayMode')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    this.consumptionFinishedSubscription = this.consumerStatusService.onDocumentConsumptionFinished().subscribe(() => {
 | 
				
			||||||
 | 
					      this.list.reload()
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
    this.route.paramMap.subscribe(params => {
 | 
					    this.route.paramMap.subscribe(params => {
 | 
				
			||||||
      this.list.clear()
 | 
					      this.list.clear()
 | 
				
			||||||
      if (params.has('id')) {
 | 
					      if (params.has('id')) {
 | 
				
			||||||
@@ -83,6 +92,12 @@ export class DocumentListComponent implements OnInit {
 | 
				
			|||||||
    })
 | 
					    })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ngOnDestroy() {
 | 
				
			||||||
 | 
					    if (this.consumptionFinishedSubscription) {
 | 
				
			||||||
 | 
					      this.consumptionFinishedSubscription.unsubscribe()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  loadViewConfig(view: PaperlessSavedView) {
 | 
					  loadViewConfig(view: PaperlessSavedView) {
 | 
				
			||||||
    this.list.load(view)
 | 
					    this.list.load(view)
 | 
				
			||||||
    this.list.reload()
 | 
					    this.list.reload()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user