mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-13 18:17:02 +01:00
Cleanup subscriptions
This commit is contained in:
parent
d733de9d9f
commit
d9cd312d07
3 changed files with 40 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||
import { from, Observable, Subscription, BehaviorSubject } from 'rxjs';
|
||||
|
|
@ -18,7 +18,7 @@ import { FILTER_FULLTEXT_QUERY } from 'src/app/data/filter-rule-type';
|
|||
templateUrl: './app-frame.component.html',
|
||||
styleUrls: ['./app-frame.component.scss']
|
||||
})
|
||||
export class AppFrameComponent {
|
||||
export class AppFrameComponent implements OnDestroy {
|
||||
|
||||
constructor (
|
||||
public router: Router,
|
||||
|
|
@ -40,6 +40,8 @@ export class AppFrameComponent {
|
|||
|
||||
searchField = new FormControl('')
|
||||
|
||||
closeAllSub: Subscription
|
||||
|
||||
get openDocuments(): PaperlessDocument[] {
|
||||
return this.openDocumentsService.getOpenDocuments()
|
||||
}
|
||||
|
|
@ -93,7 +95,7 @@ export class AppFrameComponent {
|
|||
|
||||
closeAll() {
|
||||
// user may need to confirm losing unsaved changes
|
||||
this.openDocumentsService.closeAll().subscribe(confirmed => {
|
||||
this.closeAllSub = this.openDocumentsService.closeAll().subscribe(confirmed => {
|
||||
if (confirmed) {
|
||||
this.closeMenu()
|
||||
|
||||
|
|
@ -109,6 +111,8 @@ export class AppFrameComponent {
|
|||
})
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.closeAllSub && this.closeAllSub.unsubscribe();
|
||||
}
|
||||
|
||||
get displayName() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue