From 2905fd43bfbfd5535f55b9381d0b6f20f56a707a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 22 Jun 2021 16:31:10 -0400 Subject: [PATCH] LP1929741 cleanup more PO subs Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- .../src/eg2/src/app/staff/acq/po/summary.component.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts index ae8759db24..5f2faa7543 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts @@ -1,6 +1,6 @@ -import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Component, Input, OnInit, OnDestroy, ViewChild} from '@angular/core'; import {Router} from '@angular/router'; -import {of, Observable} from 'rxjs'; +import {of, Observable, Subscription} from 'rxjs'; import {tap, take, map} from 'rxjs/operators'; import {IdlObject, IdlService} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; @@ -21,7 +21,7 @@ import {CancelDialogComponent} from '../lineitem/cancel-dialog.component'; templateUrl: 'summary.component.html', selector: 'eg-acq-po-summary' }) -export class PoSummaryComponent implements OnInit { +export class PoSummaryComponent implements OnInit, OnDestroy { private _poId: number; @Input() set poId(id: number) { @@ -44,6 +44,7 @@ export class PoSummaryComponent implements OnInit { activationBlocks: EgEvent[] = []; activationEvent: EgEvent; nameEditEnterToggled = false; + stateChangeSub: Subscription; @ViewChild('cancelDialog') cancelDialog: CancelDialogComponent; @ViewChild('progressDialog') progressDialog: ProgressDialogComponent; @@ -67,11 +68,17 @@ export class PoSummaryComponent implements OnInit { // Re-check for activation blocks if the LI service tells us // something significant happened. - this.liService.activateStateChange + this.stateChangeSub = this.liService.activateStateChange .pipe(tap(_ => this.poService.getFleshedPo(this.poId, {toCache: true}))) .subscribe(_ => this.setCanActivate()); } + ngOnDestroy() { + if (this.stateChangeSub) { + this.stateChangeSub.unsubscribe(); + } + } + po(): IdlObject { return this.poService.currentPo; } -- 2.11.0