Bugfix: Refetch unconfirmed transaction when returning back online.

This commit is contained in:
softsimon 2020-03-24 21:01:29 +07:00
parent a244458928
commit ffa97fedf3
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -3,7 +3,7 @@ import { ElectrsApiService } from '../../services/electrs-api.service';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { switchMap, filter, take } from 'rxjs/operators';
import { Transaction, Block } from '../../interfaces/electrs.interface';
import { of } from 'rxjs';
import { of, merge } from 'rxjs';
import { StateService } from '../../services/state.service';
import { WebsocketService } from '../../services/websocket.service';
import { AudioService } from 'src/app/services/audio.service';
@ -49,11 +49,19 @@ export class TransactionComponent implements OnInit, OnDestroy {
this.isLoadingTx = true;
this.transactionTime = -1;
document.body.scrollTo(0, 0);
return merge(
of(true),
this.stateService.connectionState$
.pipe(filter((state) => state === 2 && this.tx && !this.tx.status.confirmed) ),
)
.pipe(
switchMap(() => {
if (history.state.data) {
return of(history.state.data);
} else {
return this.electrsApiService.getTransaction$(this.txId);
}
return this.electrsApiService.getTransaction$(this.txId);
})
);
})
)
.subscribe((tx: Transaction) => {