Skip to content

Commit 7f036be

Browse files
committed
#457832 - Fixed transfer notification behavior
1 parent 080886e commit 7f036be

File tree

4 files changed

+9
-51
lines changed

4 files changed

+9
-51
lines changed

src/app/pages/contracts/contract-viewer/contract-viewer.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { ContractAgreementService } from "../../../shared/services/contractAgreement.service";
3-
import { firstValueFrom, from, interval, Observable, of, timer } from "rxjs";
3+
import { firstValueFrom, from, interval, Observable, of, timer, Subscription } from "rxjs";
44
import { ContractAgreement, IdResponse, TransferProcessInput } from "../../../shared/models/edc-connector-entities";
55
import { catchError, filter, finalize, first, switchMap, takeUntil, tap } from "rxjs/operators";
66
import { NotificationService } from "../../../shared/services/notification.service";
@@ -32,6 +32,7 @@ export class ContractViewerComponent implements OnInit {
3232
contracts: ContractAgreement[] = [];
3333
private runningTransfers: RunningTransferProcess[] = [];
3434
private pollingHandleTransfer?: any;
35+
private timeoutSubscription?: Subscription;
3536
PARTICIPANT_ID = `${environment.runtime.participantId}`;
3637

3738
// Pagination
@@ -203,22 +204,23 @@ export class ContractViewerComponent implements OnInit {
203204
})
204205
);
205206

207+
this.timeoutSubscription = timeout$.subscribe();
208+
206209
this.runningTransfers.push({
207210
processId: transferProcessId.id,
208211
state: TransferProcessStates.REQUESTED,
209212
contractId: contractId
210213
});
211214

212215
if (!this.pollingHandleTransfer) {
213-
this.pollingHandleTransfer = this.pollRunningTransfers(timeout$)
216+
this.pollingHandleTransfer = this.pollRunningTransfers()
214217
.pipe(finalize(() => this.cleanupPolling()))
215218
.subscribe();
216219
}
217220
}
218221

219-
private pollRunningTransfers(timeout$: Observable<number>) {
222+
private pollRunningTransfers() {
220223
return interval(2000).pipe(
221-
takeUntil(timeout$),
222224
switchMap(() => from([...this.runningTransfers])),
223225
switchMap(runningTransferProcess =>
224226
this.catalogService.getTransferProcessesById(runningTransferProcess.processId).pipe(
@@ -237,6 +239,7 @@ export class ContractViewerComponent implements OnInit {
237239
)
238240
),
239241
tap(transferProcess => {
242+
this.timeoutSubscription?.unsubscribe();
240243
this.removeTransferFromList(transferProcess.id);
241244
this.notificationService.showWarning(
242245
`Transfer [${transferProcess.id}] complete! Check if the process was successful`,
@@ -259,7 +262,6 @@ export class ContractViewerComponent implements OnInit {
259262
private cleanupPolling() {
260263
clearInterval(this.pollingHandleTransfer);
261264
this.pollingHandleTransfer = undefined;
265+
this.timeoutSubscription?.unsubscribe();
262266
}
263-
264-
265267
}

src/app/pages/transfer-history/pipes/replace.pipe.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/app/pages/transfer-history/pipes/safe.pipe.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/app/pages/transfer-history/transfer-history.module.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import { NgModule } from '@angular/core';
22
import { TransferHistoryRoutingModule } from './transfer-history-routing.module'
3-
import {ReplacePipe} from "./pipes/replace.pipe";
4-
import {SafePipe} from "./pipes/safe.pipe";
5-
63
import { TransferHistoryViewerComponent } from './transfer-history-viewer.component';
74
import { SharedModule } from 'src/app/shared/shared.module';
85

96
@NgModule({
107
declarations: [
11-
TransferHistoryViewerComponent,
12-
ReplacePipe,
13-
SafePipe
8+
TransferHistoryViewerComponent
149
],
1510
imports: [
1611
TransferHistoryRoutingModule,

0 commit comments

Comments
 (0)