refreshTransactions() {
    if (this.state.isLoading) return;
    this.setState(
      {
        showShowFlatListRefreshControl: true,
        isLoading: true,
      },
      async () => {
        let noErr = true;
        let smthChanged = false;
        try {
          /** @type {LegacyWallet} */
          let wallet = this.state.wallet;
          let balanceStart = +new Date();
          const oldBalance = wallet.getBalance();
          await wallet.fetchBalance();
          if (oldBalance !== wallet.getBalance()) smthChanged = true;
          let balanceEnd = +new Date();
          console.log(wallet.getLabel(), 'fetch balance took', (balanceEnd - balanceStart) / 1000, 'sec');
          let start = +new Date();
          const oldTxLen = wallet.getTransactions().length;
          await wallet.fetchTransactions();
          if (oldTxLen !== wallet.getTransactions().length) smthChanged = true;
          if (wallet.fetchPendingTransactions) {
            await wallet.fetchPendingTransactions();
          }
          if (wallet.fetchUserInvoices) {
            await wallet.fetchUserInvoices();
          }
          let end = +new Date();
          console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec');
        } catch (err) {
          noErr = false;
          console.warn(err);
          this.setState({
            isLoading: false,
            showShowFlatListRefreshControl: false,
          });
        }
        if (noErr && smthChanged) {
          console.log('saving to disk');
          await BlueApp.saveToDisk(); // caching
          EV(EV.enum.TRANSACTIONS_COUNT_CHANGED); // let other components know they should redraw
        }
        this.redrawScreen();
      },
    );
  }
/**
   * Forcefully fetches TXs and balance for wallet
   */
Forcefully fetches TXs and balance for wallet
Forcefully fetches TXs and balance for wallet
refreshTransactions() {
    if (this.state.isLoading) return;
    this.setState(
      {
        showShowFlatListRefreshControl: true,
        isLoading: true,
      },
      async () => {
        let noErr = true;
        let smthChanged = false;
        try {
          let wallet = this.state.wallet;
          let balanceStart = +new Date();
          const oldBalance = wallet.getBalance();
          await wallet.fetchBalance();
          if (oldBalance !== wallet.getBalance()) smthChanged = true;
          let balanceEnd = +new Date();
          console.log(wallet.getLabel(), 'fetch balance took', (balanceEnd - balanceStart) / 1000, 'sec');
          let start = +new Date();
          const oldTxLen = wallet.getTransactions().length;
          await wallet.fetchTransactions();
          if (oldTxLen !== wallet.getTransactions().length) smthChanged = true;
          if (wallet.fetchPendingTransactions) {
            await wallet.fetchPendingTransactions();
          }
          if (wallet.fetchUserInvoices) {
            await wallet.fetchUserInvoices();
          }
          let end = +new Date();
          console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec');
        } catch (err) {
          noErr = false;
          console.warn(err);
          this.setState({
            isLoading: false,
            showShowFlatListRefreshControl: false,
          });
        }
        if (noErr && smthChanged) {
          console.log('saving to disk');
          await BlueApp.saveToDisk(); 
          EV(EV.enum.TRANSACTIONS_COUNT_CHANGED); 
        }
        this.redrawScreen();
      },
    );
  }
refreshTransactions ( ) { if ( this . state . isLoading ) return ; this . setState ( { showShowFlatListRefreshControl : true , isLoading : true , } , async ( ) => { let noErr = true ; let smthChanged = false ; try { let wallet = this . state . wallet ; let balanceStart = + new Date ( ) ; const oldBalance = wallet . getBalance ( ) ; await wallet . fetchBalance ( ) ; if ( oldBalance !== wallet . getBalance ( ) ) smthChanged = true ; let balanceEnd = + new Date ( ) ; console . log ( wallet . getLabel ( ) , 'fetch balance took' , ( balanceEnd - balanceStart ) / 1000 , 'sec' ) ; let start = + new Date ( ) ; const oldTxLen = wallet . getTransactions ( ) . length ; await wallet . fetchTransactions ( ) ; if ( oldTxLen !== wallet . getTransactions ( ) . length ) smthChanged = true ; if ( wallet . fetchPendingTransactions ) { await wallet . fetchPendingTransactions ( ) ; } if ( wallet . fetchUserInvoices ) { await wallet . fetchUserInvoices ( ) ; } let end = + new Date ( ) ; console . log ( wallet . getLabel ( ) , 'fetch tx took' , ( end - start ) / 1000 , 'sec' ) ; } catch ( err ) { noErr = false ; console . warn ( err ) ; this . setState ( { isLoading : false , showShowFlatListRefreshControl : false , } ) ; } if ( noErr && smthChanged ) { console . log ( 'saving to disk' ) ; await BlueApp . saveToDisk ( ) ; EV ( EV . enum . TRANSACTIONS_COUNT_CHANGED ) ; } this . redrawScreen ( ) ; } , ) ; }
Forcefully fetches TXs and balance for wallet
Forcefully fetches TXs and balance for wallet
/** @type {LegacyWallet} */ // caching // let other components know they should redraw