From 37daf6b49016f77abe1d5a47aef2a4d5ac590230 Mon Sep 17 00:00:00 2001 From: JDonadio Date: Thu, 9 Nov 2017 15:25:51 -0300 Subject: [PATCH] fix nav params - prefix insight url - force update history --- src/pages/home/home.ts | 2 +- src/pages/tx-details/tx-details.html | 2 +- src/pages/tx-details/tx-details.ts | 29 +++++++++----------- src/pages/wallet-details/wallet-details.html | 2 +- src/pages/wallet-details/wallet-details.ts | 18 ++++++------ src/pipes/toFiat.ts | 2 +- src/pipes/toUnit.ts | 2 +- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index 9edbc2c14..63a54d4f8 100644 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -67,6 +67,6 @@ export class HomePage { } goToWalletDetails(wallet: any) { - this.navCtrl.push(WalletDetailsPage, {wallet: wallet}); + this.navCtrl.push(WalletDetailsPage, {walletId: wallet.credentials.walletId}); } } diff --git a/src/pages/tx-details/tx-details.html b/src/pages/tx-details/tx-details.html index 1bf1d1c18..1f93f616d 100644 --- a/src/pages/tx-details/tx-details.html +++ b/src/pages/tx-details/tx-details.html @@ -30,7 +30,7 @@

To

{{wallet.name || '...'}}

-

{{destinationAddress || '...'}}

+

{{tx.addressTo || '...'}}

diff --git a/src/pages/tx-details/tx-details.ts b/src/pages/tx-details/tx-details.ts index 6ee553526..b6fae62f0 100644 --- a/src/pages/tx-details/tx-details.ts +++ b/src/pages/tx-details/tx-details.ts @@ -2,6 +2,7 @@ import { Component } from "@angular/core"; import { NavParams } from 'ionic-angular'; import { TxFormatProvider } from '../../providers/tx-format/tx-format'; import { WalletProvider } from '../../providers/wallet/wallet'; +import { ProfileProvider } from '../../providers/profile/profile'; import { ExternalLinkProvider } from '../../providers/external-link/external-link'; @Component({ @@ -10,44 +11,40 @@ import { ExternalLinkProvider } from '../../providers/external-link/external-lin }) export class TxDetailsPage { public title: string; + public wallet: any; public tx: any; - public destinationAddress: string; - - private wallet: any; constructor( private navParams: NavParams, private txFormatProvider: TxFormatProvider, private walletProvider: WalletProvider, + private profileProvider: ProfileProvider, private externalLinkProvider: ExternalLinkProvider, ) { - this.wallet = this.navParams.data.wallet; - this.tx = this.navParams.data.tx; + this.wallet = this.profileProvider.getWallet(this.navParams.data.walletId); + this.tx = {}; } ionViewDidEnter() { - if (this.tx.action == 'sent') this.title = 'Sent Funds'; - if (this.tx.action == 'received') this.title = 'Received Funds'; - if (this.tx.action == 'moved') this.title = 'Moved Funds'; + const txid = this.navParams.data.txid; - this.walletProvider.getTx(this.wallet, this.tx.txid).then((tx) => { - this.updateTxParams(tx); + this.walletProvider.getTx(this.wallet, txid).then((tx) => { + this.tx = tx; + if (this.tx.action == 'sent') this.title = 'Sent Funds'; + if (this.tx.action == 'received') this.title = 'Received Funds'; + if (this.tx.action == 'moved') this.title = 'Moved Funds'; }).catch((err) => { console.log('ERROR', err); }); } - private updateTxParams(tx: any) { - this.tx = tx; - this.destinationAddress = tx.addressTo; - } - addMemo() { return; } viewOnBlockchain() { - const url = 'https://insight.bitpay.com/tx/' + this.tx.txid; + const prefix = this.wallet.coin === 'bch' ? 'bch-' : this.wallet.network === 'testnet' ? 'test-' : ''; + const url = 'https://' + prefix + 'insight.bitpay.com/tx/' + this.tx.txid; this.externalLinkProvider.open(url); } } \ No newline at end of file diff --git a/src/pages/wallet-details/wallet-details.html b/src/pages/wallet-details/wallet-details.html index e05c88ae6..ecd7fa1c4 100644 --- a/src/pages/wallet-details/wallet-details.html +++ b/src/pages/wallet-details/wallet-details.html @@ -5,7 +5,7 @@ -
+
{{wallet.status.availableBalanceStr}}
{{alternativeBalanceStr | toFiat : wallet.status.totalBalanceSat}}
diff --git a/src/pages/wallet-details/wallet-details.ts b/src/pages/wallet-details/wallet-details.ts index a9abcda24..d23fc5b29 100644 --- a/src/pages/wallet-details/wallet-details.ts +++ b/src/pages/wallet-details/wallet-details.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { NavController, NavParams } from 'ionic-angular'; import { WalletProvider } from '../../providers/wallet/wallet'; +import { ProfileProvider } from '../../providers/profile/profile'; import { TxDetailsPage } from '../../pages/tx-details/tx-details'; @Component({ @@ -9,14 +10,14 @@ import { TxDetailsPage } from '../../pages/tx-details/tx-details'; }) export class WalletDetailsPage { public wallet: any; - public alternativeBalanceStr: string; constructor( private navCtrl: NavController, private navParams: NavParams, + private profileProvider: ProfileProvider, private walletProvider: WalletProvider, ) { - this.wallet = this.navParams.data.wallet; + this.wallet = this.profileProvider.getWallet(this.navParams.data.walletId); } ionViewDidEnter() { @@ -27,16 +28,17 @@ export class WalletDetailsPage { this.getTxHistory(); } - goToTxDetails(tx: any) { - this.navCtrl.push(TxDetailsPage, {wallet: this.wallet, tx: tx}); - } - getTxHistory(force?: boolean) { - let self = this; + if (force) this.wallet.completeHistory = []; + this.walletProvider.getTxHistory_(this.wallet, {force: force}).then((txh) => { - self.wallet.completeHistory = txh; + this.wallet.completeHistory = this.wallet.completeHistory = txh; }).catch((err) => { console.log(err); }); } + + goToTxDetails(tx: any) { + this.navCtrl.push(TxDetailsPage, {walletId: this.wallet.credentials.walletId, txid: tx.txid}); + } } \ No newline at end of file diff --git a/src/pipes/toFiat.ts b/src/pipes/toFiat.ts index 3e77fd229..614c4902e 100644 --- a/src/pipes/toFiat.ts +++ b/src/pipes/toFiat.ts @@ -10,7 +10,7 @@ export class ToFiatPipe implements PipeTransform { private configProvider: ConfigProvider, private txFormatProvider: TxFormatProvider ) { - this.unitCode = this.configProvider.get()['wallet']['settings'].unitCode; + this.unitCode = this.configProvider.get().wallet.settings.unitCode; } transform(value: string, satoshis: number): any { return this.txFormatProvider.formatAlternativeStr(this.unitCode, satoshis); diff --git a/src/pipes/toUnit.ts b/src/pipes/toUnit.ts index ee1868067..657b80f53 100644 --- a/src/pipes/toUnit.ts +++ b/src/pipes/toUnit.ts @@ -10,7 +10,7 @@ export class ToUnitPipe implements PipeTransform { private configProvider: ConfigProvider, private txFormatProvider: TxFormatProvider ) { - this.unitCode = this.configProvider.get()['wallet']['settings'].unitCode; + this.unitCode = this.configProvider.get().wallet.settings.unitCode; } transform(value: string, satoshis: number): any { return this.txFormatProvider.formatAmountStr(this.unitCode, satoshis);