Fixes for send and confirm notifications

This commit is contained in:
Gabriel Masclef 2017-11-07 15:51:02 -03:00
parent 782f166ba9
commit f1d12b3863
No known key found for this signature in database
GPG Key ID: DD6D7EAADE12280D
3 changed files with 34 additions and 29 deletions

View File

@ -9,7 +9,6 @@
<ion-content>
<ion-list>
<ion-label>Sending</ion-label>
<ion-item *ngIf="!criticalError">
<!--<ion-icon ios="ios-arrow-up" md="md-arrow-up" item-left></ion-icon>-->
<div class="sending-label">
@ -23,7 +22,15 @@
</div>
</ion-item>
<ion-item *ngIf="!criticalError">
<a [hidden]="!wallet" ng-click="showWalletSelector()">
<div [hidden]="!wallet">
<span translate>To</span>
<div *ngIf="address">
<div>{{address}}</div>
</div>
</div>
</ion-item>
<ion-item *ngIf="!criticalError">
<a [hidden]="!wallet" (click)="showWalletSelector()">
<span translate>From</span>
<div class="wallet" *ngIf="wallet">
<div>{{wallet.name}}</div>
@ -35,6 +42,5 @@
</a>
</ion-item>
</ion-list>
<div>To: {{address}}</div>
<div>Amount: {{amount}}</div>
<button ion-button full (click)="approve(tx, wallet, statusChangeHandler)" [disabled]="!wallet">Send</button>
</ion-content>

View File

@ -124,7 +124,7 @@ export class ConfirmPage {
// Grab stateParams
let tx: any = {
toAmount: parseFloat(this.navParams.data.amount),
toAmount: parseFloat(this.navParams.data.amount) * 100000000, // TODO review this line '* 100000000' convert satoshi to BTC
sendMax: this.navParams.data.useSendMax == 'true' ? true : false,
toAddress: this.navParams.data.address,
description: this.navParams.data.description,
@ -559,7 +559,7 @@ export class ConfirmPage {
let okText = 'Confirm'; // TODO gettextCatalog
let cancelText = 'Cancel'; // TODO gettextCatalog
this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: boolean) => {
return reject(!ok);
return resolve(!ok);
});
});
};
@ -580,18 +580,21 @@ export class ConfirmPage {
txid: txp.txid
});
}
this.onSuccessConfirm(); // TODO review this line
}).catch((err: any) => {
this.setSendError(err);
return;
});
};
confirmTx().then(() => {
publishAndSign();
}).catch((nok: boolean) => {
confirmTx().then((nok: boolean) => {
if (nok) {
this.sendStatus = '';
return;
}
publishAndSign();
}).catch((err: any) => {
this.logger.warn(err);
return;
});
}).catch((err: any) => {

View File

@ -16,36 +16,32 @@ export class TxConfirmNotificationProvider {
public checkIfEnabled(txid: string): Promise<any> {
return new Promise((resolve, reject) => {
this.persistenceProvider.getTxConfirmNotification(txid).then((res: any) => {
return resolve(!!res);
}).catch((err: any) => {
this.logger.error(err);
return reject(err);
this.persistenceProvider.getTxConfirmNotification(txid).then((res: any) => {
return resolve(!!res);
}).catch((err: any) => {
this.logger.error(err);
return reject(err);
});
});
});
};
public subscribe(client: any, opts: any): void {
client.txConfirmationSubscribe(opts).then((res: any) => {
client.txConfirmationSubscribe(opts, (err: any, res: any) => {
if (err) this.logger.error(err);
this.persistenceProvider.setTxConfirmNotification(opts.txid, true).catch((err: any) => {
this.logger.error(err);
return;
});
}).catch((err: any) => {
this.logger.error(err);
return;
this.logger.error(err);
return;
});
});
};
public unsubscribe(client: any, txId: string): void {
client.txConfirmationUnsubscribe(txId).then((res: any) => {
client.txConfirmationUnsubscribe(txId, (err: any, res: any) => {
if (err) this.logger.error(err);
this.persistenceProvider.removeTxConfirmNotification(txId).catch((err: any) => {
this.logger.error(err);
return;
});
}).catch((err: any) => {
this.logger.error(err);
return;
this.logger.error(err);
return;
});
});
};