fix nav params - prefix insight url - force update history

This commit is contained in:
JDonadio 2017-11-09 15:25:51 -03:00
parent 411622d843
commit 37daf6b490
No known key found for this signature in database
GPG Key ID: EC1F4E04B2BFA730
7 changed files with 28 additions and 29 deletions

View File

@ -67,6 +67,6 @@ export class HomePage {
}
goToWalletDetails(wallet: any) {
this.navCtrl.push(WalletDetailsPage, {wallet: wallet});
this.navCtrl.push(WalletDetailsPage, {walletId: wallet.credentials.walletId});
}
}

View File

@ -30,7 +30,7 @@
</ion-avatar>
<h2 translate>To</h2>
<p *ngIf="tx.action != 'sent'">{{wallet.name || '...'}}</p>
<p *ngIf="tx.action == 'sent'">{{destinationAddress || '...'}}</p>
<p *ngIf="tx.action == 'sent'">{{tx.addressTo || '...'}}</p>
</ion-item>
<ion-item *ngIf="tx.action == 'sent'">

View File

@ -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);
}
}

View File

@ -5,7 +5,7 @@
</ion-header>
<ion-content>
<div class="balance-header">
<div class="balance-header" (click)="getTxHistory(true)">
<div class="balance-str">{{wallet.status.availableBalanceStr}}</div>
<div class="balance-alt-str">{{alternativeBalanceStr | toFiat : wallet.status.totalBalanceSat}}</div>
</div>

View File

@ -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});
}
}

View File

@ -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);

View File

@ -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);