Load more mempool transactions
This commit is contained in:
		
							parent
							
								
									427b1ef617
								
							
						
					
					
						commit
						5ccaa31cf9
					
				@ -207,7 +207,7 @@ export class AddressComponent implements OnInit, OnDestroy {
 | 
			
		||||
    }
 | 
			
		||||
    this.isLoadingTransactions = true;
 | 
			
		||||
    this.retryLoadMore = false;
 | 
			
		||||
    this.electrsApiService.getAddressTransactionsFromHash$(this.address.address, this.lastTransactionTxId)
 | 
			
		||||
    this.electrsApiService.getAddressTransactions$(this.address.address, this.lastTransactionTxId)
 | 
			
		||||
      .subscribe((transactions: Transaction[]) => {
 | 
			
		||||
        this.lastTransactionTxId = transactions[transactions.length - 1].txid;
 | 
			
		||||
        this.loadedConfirmedTxCount += transactions.length;
 | 
			
		||||
@ -217,6 +217,10 @@ export class AddressComponent implements OnInit, OnDestroy {
 | 
			
		||||
      (error) => {
 | 
			
		||||
        this.isLoadingTransactions = false;
 | 
			
		||||
        this.retryLoadMore = true;
 | 
			
		||||
        // In the unlikely event of the txid wasn't found in the mempool anymore and we must reload the page.
 | 
			
		||||
        if (error.status === 422) {
 | 
			
		||||
          window.location.reload();
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { Injectable } from '@angular/core';
 | 
			
		||||
import { HttpClient } from '@angular/common/http';
 | 
			
		||||
import { HttpClient, HttpParams } from '@angular/common/http';
 | 
			
		||||
import { Observable } from 'rxjs';
 | 
			
		||||
import { Transaction, Address, Outspend, Recent, Asset } from '../interfaces/electrs.interface';
 | 
			
		||||
import { StateService } from './state.service';
 | 
			
		||||
@ -65,12 +65,12 @@ export class ElectrsApiService {
 | 
			
		||||
    return this.httpClient.get<Address>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getAddressTransactions$(address: string): Observable<Transaction[]> {
 | 
			
		||||
    return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address + '/txs');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getAddressTransactionsFromHash$(address: string, txid: string): Observable<Transaction[]> {
 | 
			
		||||
    return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address + '/txs/chain/' + txid);
 | 
			
		||||
  getAddressTransactions$(address: string,  txid?: string): Observable<Transaction[]> {
 | 
			
		||||
    let params = new HttpParams();
 | 
			
		||||
    if (txid) {
 | 
			
		||||
      params = params.append('after_txid', txid);
 | 
			
		||||
    }
 | 
			
		||||
    return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/address/' + address + '/txs', { params });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getAsset$(assetId: string): Observable<Asset> {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user