Merge pull request #8075 from gabrielbazan7/ref/ongoingprocess

REF: using clear to remove process
This commit is contained in:
Gabriel Masclef 2018-02-22 13:17:30 -03:00 committed by GitHub
commit b3d5b40240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 210 additions and 206 deletions

View File

@ -91,16 +91,16 @@ export class CopayersPage {
} }
private deleteWallet(): void { private deleteWallet(): void {
this.onGoingProcessProvider.set('deletingWallet', true); this.onGoingProcessProvider.set('deletingWallet');
this.profileProvider.deleteWalletClient(this.wallet).then(() => { this.profileProvider.deleteWalletClient(this.wallet).then(() => {
this.onGoingProcessProvider.set('deletingWallet', false); this.onGoingProcessProvider.clear();
this.pushNotificationsProvider.unsubscribe(this.wallet); this.pushNotificationsProvider.unsubscribe(this.wallet);
this.navCtrl.popToRoot().then(() => { this.navCtrl.popToRoot().then(() => {
this.navCtrl.parent.select(0); this.navCtrl.parent.select(0);
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('deletingWallet', false); this.onGoingProcessProvider.clear();
let errorText = this.translate.instant('Error'); let errorText = this.translate.instant('Error');
this.popupProvider.ionicAlert(errorText, err.message || err); this.popupProvider.ionicAlert(errorText, err.message || err);
}); });

View File

@ -194,10 +194,10 @@ export class CreateWalletPage implements OnInit {
} }
private create(opts: any): void { private create(opts: any): void {
this.onGoingProcessProvider.set('creatingWallet', true); this.onGoingProcessProvider.set('creatingWallet');
this.profileProvider.createWallet(opts).then((wallet: any) => { this.profileProvider.createWallet(opts).then((wallet: any) => {
this.onGoingProcessProvider.set('creatingWallet', false); this.onGoingProcessProvider.clear();
this.events.publish('status:updated'); this.events.publish('status:updated');
this.walletProvider.updateRemotePreferences(wallet); this.walletProvider.updateRemotePreferences(wallet);
this.pushNotificationsProvider.updateSubscription(wallet); this.pushNotificationsProvider.updateSubscription(wallet);
@ -213,7 +213,7 @@ export class CreateWalletPage implements OnInit {
this.navCtrl.popToRoot(); this.navCtrl.popToRoot();
} }
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('creatingWallet', false); this.onGoingProcessProvider.clear();
this.logger.warn(err); this.logger.warn(err);
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
this.popupProvider.ionicAlert(title, err); this.popupProvider.ionicAlert(title, err);

View File

@ -184,16 +184,16 @@ export class ImportWalletPage {
return; return;
} }
this.onGoingProcessProvider.set('importingWallet', true); this.onGoingProcessProvider.set('importingWallet');
opts.compressed = null; opts.compressed = null;
opts.password = null; opts.password = null;
setTimeout(() => { setTimeout(() => {
this.profileProvider.importWallet(str2, opts).then((wallet: any) => { this.profileProvider.importWallet(str2, opts).then((wallet: any) => {
this.onGoingProcessProvider.set('importingWallet', false); this.onGoingProcessProvider.clear();
this.finish(wallet); this.finish(wallet);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('importingWallet', false); this.onGoingProcessProvider.clear();
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
this.popupProvider.ionicAlert(title, err); this.popupProvider.ionicAlert(title, err);
return; return;
@ -223,10 +223,10 @@ export class ImportWalletPage {
} }
private importExtendedPrivateKey(xPrivKey, opts) { private importExtendedPrivateKey(xPrivKey, opts) {
this.onGoingProcessProvider.set('importingWallet', true); this.onGoingProcessProvider.set('importingWallet');
setTimeout(() => { setTimeout(() => {
this.profileProvider.importExtendedPrivateKey(xPrivKey, opts).then((wallet: any) => { this.profileProvider.importExtendedPrivateKey(xPrivKey, opts).then((wallet: any) => {
this.onGoingProcessProvider.set('importingWallet', false); this.onGoingProcessProvider.clear();
this.finish(wallet); this.finish(wallet);
}).catch((err: any) => { }).catch((err: any) => {
if (err instanceof this.errors.NOT_AUTHORIZED) { if (err instanceof this.errors.NOT_AUTHORIZED) {
@ -235,17 +235,17 @@ export class ImportWalletPage {
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
this.popupProvider.ionicAlert(title, err); this.popupProvider.ionicAlert(title, err);
} }
this.onGoingProcessProvider.set('importingWallet', false); this.onGoingProcessProvider.clear();
return; return;
}); });
}, 100); }, 100);
} }
private importMnemonic(words: string, opts: any): void { private importMnemonic(words: string, opts: any): void {
this.onGoingProcessProvider.set('importingWallet', true); this.onGoingProcessProvider.set('importingWallet');
setTimeout(() => { setTimeout(() => {
this.profileProvider.importMnemonic(words, opts).then((wallet: any) => { this.profileProvider.importMnemonic(words, opts).then((wallet: any) => {
this.onGoingProcessProvider.set('importingWallet', false); this.onGoingProcessProvider.clear();
this.finish(wallet); this.finish(wallet);
}).catch((err: any) => { }).catch((err: any) => {
if (err instanceof this.errors.NOT_AUTHORIZED) { if (err instanceof this.errors.NOT_AUTHORIZED) {
@ -254,7 +254,7 @@ export class ImportWalletPage {
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
this.popupProvider.ionicAlert(title, err); this.popupProvider.ionicAlert(title, err);
} }
this.onGoingProcessProvider.set('importingWallet', false); this.onGoingProcessProvider.clear();
return; return;
}); });
}, 100); }, 100);

View File

@ -144,10 +144,10 @@ export class JoinWalletPage {
} }
private join(opts: any): void { private join(opts: any): void {
this.onGoingProcessProvider.set('joiningWallet', true); this.onGoingProcessProvider.set('joiningWallet');
this.profileProvider.joinWallet(opts).then((wallet: any) => { this.profileProvider.joinWallet(opts).then((wallet: any) => {
this.onGoingProcessProvider.set('joiningWallet', false); this.onGoingProcessProvider.clear();
this.events.publish('status:updated'); this.events.publish('status:updated');
this.walletProvider.updateRemotePreferences(wallet); this.walletProvider.updateRemotePreferences(wallet);
@ -158,7 +158,7 @@ export class JoinWalletPage {
this.navCtrl.popToRoot(); this.navCtrl.popToRoot();
} }
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('joiningWallet', false); this.onGoingProcessProvider.clear();
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
this.popupProvider.ionicAlert(title, err); this.popupProvider.ionicAlert(title, err);
return; return;

View File

@ -246,12 +246,12 @@ export class BackupGamePage {
}; };
private finalStep(): void { private finalStep(): void {
this.onGoingProcessProvider.set('validatingWords', true); this.onGoingProcessProvider.set('validatingWords');
this.confirm().then(() => { this.confirm().then(() => {
this.onGoingProcessProvider.set('validatingWords', false); this.onGoingProcessProvider.clear();
this.showBackupResult(); this.showBackupResult();
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('validatingWords', false); this.onGoingProcessProvider.clear();
this.logger.error('Failed to verify backup: ', err); this.logger.error('Failed to verify backup: ', err);
this.error = true; this.error = true;
let showError = this.alertCtrl.create({ let showError = this.alertCtrl.create({

View File

@ -98,10 +98,10 @@ export class SendFeedbackPage {
"deviceVersion": versionStr "deviceVersion": versionStr
}; };
if (!goHome) this.onGoingProcessProvider.set('sendingFeedback', true); if (!goHome) this.onGoingProcessProvider.set('sendingFeedback');
this.feedbackProvider.send(dataSrc).then(() => { this.feedbackProvider.send(dataSrc).then(() => {
if (goHome) return; if (goHome) return;
this.onGoingProcessProvider.set('sendingFeedback', false); this.onGoingProcessProvider.clear();
if (!this.score) { if (!this.score) {
let title = this.translate.instant('Thank you!'); let title = this.translate.instant('Thank you!');
let message = this.translate.instant('A member of the team will review your feedback as soon as possible.'); let message = this.translate.instant('A member of the team will review your feedback as soon as possible.');
@ -116,7 +116,7 @@ export class SendFeedbackPage {
} }
}).catch((err) => { }).catch((err) => {
if (goHome) return; if (goHome) return;
this.onGoingProcessProvider.set('sendingFeedback', false); this.onGoingProcessProvider.clear();
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
let subtitle = this.translate.instant('Feedback could not be submitted. Please try again later.'); let subtitle = this.translate.instant('Feedback could not be submitted. Please try again later.');
this.popupProvider.ionicAlert(title, subtitle); this.popupProvider.ionicAlert(title, subtitle);

View File

@ -39,9 +39,9 @@ export class ActivityPage {
ionViewWillEnter() { ionViewWillEnter() {
let loading = this.translate.instant('Updating... Please stand by'); let loading = this.translate.instant('Updating... Please stand by');
this.onGoingProcessProvider.set(loading, true); this.onGoingProcessProvider.set(loading);
this.profileProvider.getNotifications(50).then((nData: any) => { this.profileProvider.getNotifications(50).then((nData: any) => {
this.onGoingProcessProvider.set(loading, false); this.onGoingProcessProvider.clear();
this.notifications = nData.notifications; this.notifications = nData.notifications;
this.profileProvider.getTxps({}).then((txpsData: any) => { this.profileProvider.getTxps({}).then((txpsData: any) => {
this.txps = txpsData.txps; this.txps = txpsData.txps;
@ -49,6 +49,7 @@ export class ActivityPage {
this.logger.error(err); this.logger.error(err);
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.clear();
this.logger.error(err); this.logger.error(err);
}); });
} }
@ -67,13 +68,14 @@ export class ActivityPage {
modal.present(); modal.present();
} }
else { else {
this.onGoingProcessProvider.set('loadingTxInfo', true); this.onGoingProcessProvider.set('loadingTxInfo');
this.walletProvider.getTxp(wallet, n.txpId).then((txp) => { this.walletProvider.getTxp(wallet, n.txpId).then((txp) => {
let _txp = txp; let _txp = txp;
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
let modal = this.modalCtrl.create(TxpDetailsPage, { tx: _txp }, { showBackdrop: false, enableBackdropDismiss: false }); let modal = this.modalCtrl.create(TxpDetailsPage, { tx: _txp }, { showBackdrop: false, enableBackdropDismiss: false });
modal.present(); modal.present();
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.clear();
this.logger.warn('No txp found'); this.logger.warn('No txp found');
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
let subtitle = this.translate.instant('Transaction not found'); let subtitle = this.translate.instant('Transaction not found');

View File

@ -179,8 +179,8 @@ export class HomePage {
this.walletsBch = this.profileProvider.getWallets({ coin: 'bch' }); this.walletsBch = this.profileProvider.getWallets({ coin: 'bch' });
this.updateAllWallets(); this.updateAllWallets();
}, 10000, { }, 10000, {
'leading': true 'leading': true
}); });
public checkHomeTip(): void { public checkHomeTip(): void {
this.persistenceProvider.getHomeTipAccepted().then((value: string) => { this.persistenceProvider.getHomeTipAccepted().then((value: string) => {
@ -249,8 +249,8 @@ export class HomePage {
this.logger.error(err); this.logger.error(err);
}); });
}, 5000, { }, 5000, {
'leading': true 'leading': true
}); });
private getNotifications = _.debounce(() => { private getNotifications = _.debounce(() => {
this.profileProvider.getNotifications({ limit: 3 }).then((data: any) => { this.profileProvider.getNotifications({ limit: 3 }).then((data: any) => {
@ -262,8 +262,8 @@ export class HomePage {
this.logger.error(err); this.logger.error(err);
}); });
}, 5000, { }, 5000, {
'leading': true 'leading': true
}); });
private updateAllWallets(): void { private updateAllWallets(): void {
let wallets: any[] = []; let wallets: any[] = [];
@ -357,12 +357,13 @@ export class HomePage {
if (txp) { if (txp) {
this.openTxpModal(txp); this.openTxpModal(txp);
} else { } else {
this.onGoingProcessProvider.set('loadingTxInfo', true); this.onGoingProcessProvider.set('loadingTxInfo');
this.walletProvider.getTxp(wallet, n.txpId).then((txp: any) => { this.walletProvider.getTxp(wallet, n.txpId).then((txp: any) => {
var _txp = txp; var _txp = txp;
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
this.openTxpModal(_txp); this.openTxpModal(_txp);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
this.logger.warn('No txp found'); this.logger.warn('No txp found');
let title = this.translate.instant('Error'); let title = this.translate.instant('Error');
let subtitle = this.translate.instant('Transaction not found'); let subtitle = this.translate.instant('Transaction not found');

View File

@ -30,12 +30,12 @@ export class ProposalsPage {
this.addressbook = ab || {}; this.addressbook = ab || {};
let loading = this.translate.instant('Updating pending proposals... Please stand by'); let loading = this.translate.instant('Updating pending proposals... Please stand by');
this.onGoingProcessProvider.set(loading, true); this.onGoingProcessProvider.set(loading);
this.profileProvider.getTxps(50).then((txpsData) => { this.profileProvider.getTxps(50).then((txpsData) => {
this.onGoingProcessProvider.set(loading, false); this.onGoingProcessProvider.clear();
this.txps = txpsData.txps; this.txps = txpsData.txps;
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set(loading, false); this.onGoingProcessProvider.clear();
this.logger.error(err); this.logger.error(err);
}); });
}).catch((err: any) => { }).catch((err: any) => {

View File

@ -37,9 +37,9 @@ export class AmazonCardDetailsPage {
} }
public cancelGiftCard(): void { public cancelGiftCard(): void {
this.onGoingProcessProvider.set('cancelingGiftCard', true); this.onGoingProcessProvider.set('cancelingGiftCard');
this.amazonProvider.cancelGiftCard(this.card, (err: any, data: any) => { this.amazonProvider.cancelGiftCard(this.card, (err: any, data: any) => {
this.onGoingProcessProvider.set('cancelingGiftCard', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.popupProvider.ionicAlert('Error canceling gift card', this.bwcErrorProvider.msg(err)); this.popupProvider.ionicAlert('Error canceling gift card', this.bwcErrorProvider.msg(err));
return; return;
@ -61,9 +61,9 @@ export class AmazonCardDetailsPage {
public refreshGiftCard(): void { public refreshGiftCard(): void {
if (!this.updateGiftCard) return; if (!this.updateGiftCard) return;
this.onGoingProcessProvider.set('updatingGiftCard', true); this.onGoingProcessProvider.set('updatingGiftCard');
this.amazonProvider.getPendingGiftCards((err: any, gcds: any) => { this.amazonProvider.getPendingGiftCards((err: any, gcds: any) => {
this.onGoingProcessProvider.set('updatingGiftCard', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.popupProvider.ionicAlert('Error', err); this.popupProvider.ionicAlert('Error', err);
return; return;

View File

@ -152,8 +152,10 @@ export class BuyAmazonPage {
} }
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => { this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
return resolve(txp); return resolve(txp);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
return reject(err); return reject(err);
}); });
}); });
@ -289,7 +291,7 @@ export class BuyAmazonPage {
remove: true remove: true
}, (err: any) => { }, (err: any) => {
this.logger.error(err); this.logger.error(err);
this.onGoingProcessProvider.set('buyingGiftCard', false); this.onGoingProcessProvider.clear();
this.showError(null, this.translate.instant('Gift card expired')); this.showError(null, this.translate.instant('Gift card expired'));
}); });
return; return;
@ -305,7 +307,7 @@ export class BuyAmazonPage {
} }
this.amazonProvider.savePendingGiftCard(newData, null, (err: any) => { this.amazonProvider.savePendingGiftCard(newData, null, (err: any) => {
this.onGoingProcessProvider.set('buyingGiftCard', false); this.onGoingProcessProvider.clear();
this.logger.debug("Saved new gift card with status: " + newData.status); this.logger.debug("Saved new gift card with status: " + newData.status);
this.amazonGiftCard = newData; this.amazonGiftCard = newData;
this.openFinishModal(); this.openFinishModal();
@ -326,7 +328,7 @@ export class BuyAmazonPage {
uuid: wallet.id, uuid: wallet.id,
email email
}; };
this.onGoingProcessProvider.set('loadingTxInfo', true); this.onGoingProcessProvider.set('loadingTxInfo');
this.createInvoice(dataSrc).then((data: any) => { this.createInvoice(dataSrc).then((data: any) => {
let invoice = data.invoice; let invoice = data.invoice;
@ -339,7 +341,7 @@ export class BuyAmazonPage {
this.message = this.amountUnitStr + " for Amazon.com Gift Card"; // TODO: translate this.message = this.amountUnitStr + " for Amazon.com Gift Card"; // TODO: translate
this.createTx(wallet, invoice, this.message).then((ctxp: any) => { this.createTx(wallet, invoice, this.message).then((ctxp: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
// Save in memory // Save in memory
@ -362,13 +364,13 @@ export class BuyAmazonPage {
this.setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee); this.setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
this._resetValues(); this._resetValues();
this.showError(err.title, err.message); this.showError(err.title, err.message);
return; return;
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err.title, err.message); this.showErrorAndBack(err.title, err.message);
return; return;
}); });
@ -388,7 +390,7 @@ export class BuyAmazonPage {
} }
this.publishAndSign(this.wallet, this.createdTx).then((txSent) => { this.publishAndSign(this.wallet, this.createdTx).then((txSent) => {
this.onGoingProcessProvider.set('buyingGiftCard', true); this.onGoingProcessProvider.set('buyingGiftCard');
this.checkTransaction(1, this.createdTx.giftData); this.checkTransaction(1, this.createdTx.giftData);
}).catch((err: any) => { }).catch((err: any) => {
this._resetValues(); this._resetValues();

View File

@ -165,8 +165,10 @@ export class BitPayCardTopUpPage {
} }
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => { this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
return resolve(txp); return resolve(txp);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
return reject(err); return reject(err);
}); });
}); });
@ -334,7 +336,7 @@ export class BitPayCardTopUpPage {
amount: parsedAmount.amount, amount: parsedAmount.amount,
currency: parsedAmount.currency currency: parsedAmount.currency
}; };
this.onGoingProcessProvider.set('loadingTxInfo', true); this.onGoingProcessProvider.set('loadingTxInfo');
this.createInvoice(dataSrc).then((invoice) => { this.createInvoice(dataSrc).then((invoice) => {
// Sometimes API does not return this element; // Sometimes API does not return this element;
invoice['buyerPaidBtcMinerFee'] = invoice.buyerPaidBtcMinerFee || 0; invoice['buyerPaidBtcMinerFee'] = invoice.buyerPaidBtcMinerFee || 0;
@ -384,12 +386,12 @@ export class BitPayCardTopUpPage {
return; return;
} }
this.onGoingProcessProvider.set('topup', true); this.onGoingProcessProvider.set('topup');
this.publishAndSign(this.wallet, this.createdTx).then((txSent) => { this.publishAndSign(this.wallet, this.createdTx).then((txSent) => {
this.onGoingProcessProvider.set('topup', false); this.onGoingProcessProvider.clear();
this.openFinishModal(); this.openFinishModal();
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('topup', false); this.onGoingProcessProvider.clear();
this._resetValues(); this._resetValues();
this.showError(this.translate.instant('Could not send transaction'), err); this.showError(this.translate.instant('Could not send transaction'), err);
}); });
@ -398,12 +400,12 @@ export class BitPayCardTopUpPage {
public onWalletSelect(wallet: any): void { public onWalletSelect(wallet: any): void {
this.wallet = wallet; this.wallet = wallet;
this.onGoingProcessProvider.set('retrievingInputs', true); this.onGoingProcessProvider.set('retrievingInputs');
this.calculateAmount(this.wallet).then((val: any) => { this.calculateAmount(this.wallet).then((val: any) => {
let parsedAmount = this.txFormatProvider.parseAmount(this.coin, val.amount, val.currency); let parsedAmount = this.txFormatProvider.parseAmount(this.coin, val.amount, val.currency);
this.initializeTopUp(this.wallet, parsedAmount); this.initializeTopUp(this.wallet, parsedAmount);
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('retrievingInputs', false); this.onGoingProcessProvider.clear();
this._resetValues(); this._resetValues();
this.showError(err.title, err.message).then(() => { this.showError(err.title, err.message).then(() => {
this.showWallets(); this.showWallets();

View File

@ -92,10 +92,10 @@ export class BuyCoinbasePage {
} }
private processPaymentInfo(): void { private processPaymentInfo(): void {
this.onGoingProcessProvider.set('connectingCoinbase', true); this.onGoingProcessProvider.set('connectingCoinbase');
this.coinbaseProvider.init((err: any, res: any) => { this.coinbaseProvider.init((err: any, res: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
} }
@ -109,7 +109,7 @@ export class BuyCoinbasePage {
this.selectedPaymentMethodId = null; this.selectedPaymentMethodId = null;
this.coinbaseProvider.getPaymentMethods(accessToken, (err: any, p: any) => { this.coinbaseProvider.getPaymentMethods(accessToken, (err: any, p: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
} }
@ -127,7 +127,7 @@ export class BuyCoinbasePage {
} }
} }
if (_.isEmpty(this.paymentMethods)) { if (_.isEmpty(this.paymentMethods)) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
let url = 'https://support.coinbase.com/customer/portal/articles/1148716-payment-methods-for-us-customers'; let url = 'https://support.coinbase.com/customer/portal/articles/1148716-payment-methods-for-us-customers';
let msg = 'No payment method available to buy'; let msg = 'No payment method available to buy';
let okText = 'More info'; let okText = 'More info';
@ -146,10 +146,9 @@ export class BuyCoinbasePage {
} }
public buyRequest(): void { public buyRequest(): void {
this.onGoingProcessProvider.set('connectingCoinbase', true);
this.coinbaseProvider.init((err, res) => { this.coinbaseProvider.init((err, res) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
} }
@ -162,7 +161,7 @@ export class BuyCoinbasePage {
quote: true quote: true
}; };
this.coinbaseProvider.buyRequest(accessToken, accountId, dataSrc, (err: any, data: any) => { this.coinbaseProvider.buyRequest(accessToken, accountId, dataSrc, (err: any, data: any) => {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
@ -179,10 +178,10 @@ export class BuyCoinbasePage {
this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: boolean) => { this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: boolean) => {
if (!ok) return; if (!ok) return;
this.onGoingProcessProvider.set('buyingBitcoin', true); this.onGoingProcessProvider.set('buyingBitcoin');
this.coinbaseProvider.init((err: any, res: any) => { this.coinbaseProvider.init((err: any, res: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
@ -196,7 +195,7 @@ export class BuyCoinbasePage {
}; };
this.coinbaseProvider.buyRequest(accessToken, accountId, dataSrc, (err: any, b: any) => { this.coinbaseProvider.buyRequest(accessToken, accountId, dataSrc, (err: any, b: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
@ -216,14 +215,14 @@ export class BuyCoinbasePage {
private processBuyTx(tx: any): void { private processBuyTx(tx: any): void {
if (!tx) { if (!tx) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError('Transaction not found'); this.showError('Transaction not found');
return; return;
} }
this.coinbaseProvider.getTransaction(this.accessToken, this.accountId, tx.id, (err: any, updatedTx: any) => { this.coinbaseProvider.getTransaction(this.accessToken, this.accountId, tx.id, (err: any, updatedTx: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
@ -234,12 +233,12 @@ export class BuyCoinbasePage {
this.logger.debug('Saving transaction to process later...'); this.logger.debug('Saving transaction to process later...');
this.coinbaseProvider.savePendingTransaction(updatedTx.data, {}, (err: any) => { this.coinbaseProvider.savePendingTransaction(updatedTx.data, {}, (err: any) => {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
if (err) this.logger.debug(err); if (err) this.logger.debug(err);
this.openFinishModal(); this.openFinishModal();
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
}); });
}); });
@ -248,7 +247,7 @@ export class BuyCoinbasePage {
private _processBuyOrder(b: any): void { private _processBuyOrder(b: any): void {
this.coinbaseProvider.getBuyOrder(this.accessToken, this.accountId, b.data.id, (err: any, buyResp: any) => { this.coinbaseProvider.getBuyOrder(this.accessToken, this.accountId, b.data.id, (err: any, buyResp: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
@ -281,9 +280,9 @@ export class BuyCoinbasePage {
this.currency = 'BTC'; this.currency = 'BTC';
this.amountUnitStr = parsedAmount.amountUnitStr; this.amountUnitStr = parsedAmount.amountUnitStr;
this.onGoingProcessProvider.set('calculatingFee', true); this.onGoingProcessProvider.set('calculatingFee');
this.coinbaseProvider.checkEnoughFundsForFee(this.amount, (err: any) => { this.coinbaseProvider.checkEnoughFundsForFee(this.amount, (err: any) => {
this.onGoingProcessProvider.set('calculatingFee', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;

View File

@ -26,10 +26,10 @@ export class CoinbaseSettingsPage {
} }
ionViewDidLoad() { ionViewDidLoad() {
this.onGoingProcessProvider.set('connectingCoinbase', true); this.onGoingProcessProvider.set('connectingCoinbase');
this.coinbaseProvider.init((err, data) => { this.coinbaseProvider.init((err, data) => {
if (err || _.isEmpty(data)) { if (err || _.isEmpty(data)) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.logger.error(err); this.logger.error(err);
let errorId = err.errors ? err.errors[0].id : null; let errorId = err.errors ? err.errors[0].id : null;
@ -46,7 +46,7 @@ export class CoinbaseSettingsPage {
let accessToken = data.accessToken; let accessToken = data.accessToken;
let accountId = data.accountId; let accountId = data.accountId;
this.coinbaseProvider.getAccount(accessToken, accountId, (err, account) => { this.coinbaseProvider.getAccount(accessToken, accountId, (err, account) => {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.coinbaseAccount = account.data[0]; this.coinbaseAccount = account.data[0];
}); });
this.coinbaseProvider.getCurrentUser(accessToken, (err, user) => { this.coinbaseProvider.getCurrentUser(accessToken, (err, user) => {

View File

@ -139,9 +139,9 @@ export class CoinbasePage {
} }
public submitOauthCode(code: string): void { public submitOauthCode(code: string): void {
this.onGoingProcessProvider.set('connectingCoinbase', true); this.onGoingProcessProvider.set('connectingCoinbase');
this.coinbaseProvider.getToken(code, (err: string, accessToken: string) => { this.coinbaseProvider.getToken(code, (err: string, accessToken: string) => {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.popupProvider.ionicAlert('Error connecting to Coinbase', err); this.popupProvider.ionicAlert('Error connecting to Coinbase', err);
return; return;

View File

@ -107,20 +107,21 @@ export class SellCoinbasePage {
this.logger.info(err); this.logger.info(err);
return reject(err); return reject(err);
} }
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => { this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
return resolve(txp); return resolve(txp);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
return reject(err); return reject(err);
}); });
}); });
} }
private processPaymentInfo(): void { private processPaymentInfo(): void {
this.onGoingProcessProvider.set('connectingCoinbase', true); this.onGoingProcessProvider.set('connectingCoinbase');
this.coinbaseProvider.init((err: any, res: any) => { this.coinbaseProvider.init((err: any, res: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors)); this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors));
return; return;
} }
@ -134,7 +135,7 @@ export class SellCoinbasePage {
this.selectedPaymentMethodId = null; this.selectedPaymentMethodId = null;
this.coinbaseProvider.getPaymentMethods(accessToken, (err: any, p: any) => { this.coinbaseProvider.getPaymentMethods(accessToken, (err: any, p: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors)); this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors));
return; return;
} }
@ -152,7 +153,7 @@ export class SellCoinbasePage {
} }
} }
if (_.isEmpty(this.paymentMethods)) { if (_.isEmpty(this.paymentMethods)) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
let url = 'https://support.coinbase.com/customer/portal/articles/1148716-payment-methods-for-us-customers'; let url = 'https://support.coinbase.com/customer/portal/articles/1148716-payment-methods-for-us-customers';
let msg = 'No payment method available to buy'; let msg = 'No payment method available to buy';
let okText = 'More info'; let okText = 'More info';
@ -216,7 +217,7 @@ export class SellCoinbasePage {
ctx.sell_price_currency = sellPrice ? sellPrice.currency : 'USD'; ctx.sell_price_currency = sellPrice ? sellPrice.currency : 'USD';
ctx.description = this.appProvider.info.nameCase + ' Wallet: ' + this.wallet.name; ctx.description = this.appProvider.info.nameCase + ' Wallet: ' + this.wallet.name;
this.coinbaseProvider.savePendingTransaction(ctx, null, (err: any) => { this.coinbaseProvider.savePendingTransaction(ctx, null, (err: any) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.openFinishModal(); this.openFinishModal();
if (err) this.logger.debug(this.coinbaseProvider.getErrorsAsString(err.errors)); if (err) this.logger.debug(this.coinbaseProvider.getErrorsAsString(err.errors));
}); });
@ -229,7 +230,7 @@ export class SellCoinbasePage {
if (count < 5) { if (count < 5) {
this.checkTransaction(count + 1, txp); this.checkTransaction(count + 1, txp);
} else { } else {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError('No transaction found'); this.showError('No transaction found');
return; return;
} }
@ -242,10 +243,9 @@ export class SellCoinbasePage {
}); });
public sellRequest(): void { public sellRequest(): void {
this.onGoingProcessProvider.set('connectingCoinbase', true);
this.coinbaseProvider.init((err: any, res: any) => { this.coinbaseProvider.init((err: any, res: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors)); this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors));
return; return;
} }
@ -258,7 +258,7 @@ export class SellCoinbasePage {
quote: true quote: true
}; };
this.coinbaseProvider.sellRequest(accessToken, accountId, dataSrc, (err: any, data: any) => { this.coinbaseProvider.sellRequest(accessToken, accountId, dataSrc, (err: any, data: any) => {
this.onGoingProcessProvider.set('connectingCoinbase', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors)); this.showErrorAndBack(this.coinbaseProvider.getErrorsAsString(err.errors));
return; return;
@ -279,10 +279,10 @@ export class SellCoinbasePage {
this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: any) => { this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok: any) => {
if (!ok) return; if (!ok) return;
this.onGoingProcessProvider.set('sellingBitcoin', true); this.onGoingProcessProvider.set('sellingBitcoin');
this.coinbaseProvider.init((err: any, res: any) => { this.coinbaseProvider.init((err: any, res: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(this.coinbaseProvider.getErrorsAsString(err.errors)); this.showError(this.coinbaseProvider.getErrorsAsString(err.errors));
return; return;
} }
@ -294,7 +294,7 @@ export class SellCoinbasePage {
}; };
this.coinbaseProvider.createAddress(accessToken, accountId, dataSrc, (err: any, data: any) => { this.coinbaseProvider.createAddress(accessToken, accountId, dataSrc, (err: any, data: any) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(this.coinbaseProvider.getErrorsAsString(err.errors)); this.showError(this.coinbaseProvider.getErrorsAsString(err.errors));
return; return;
} }
@ -325,12 +325,12 @@ export class SellCoinbasePage {
this.logger.debug('Transaction broadcasted. Wait for Coinbase confirmation...'); this.logger.debug('Transaction broadcasted. Wait for Coinbase confirmation...');
this.checkTransaction(1, txSent); this.checkTransaction(1, txSent);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
}); });

View File

@ -87,10 +87,10 @@ export class BuyGlideraPage {
} }
private processPaymentInfo(): void { private processPaymentInfo(): void {
this.onGoingProcessProvider.set('connectingGlidera', true); this.onGoingProcessProvider.set('connectingGlidera');
this.glideraProvider.init((err, data) => { this.glideraProvider.init((err, data) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingGlidera', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
} }
@ -102,7 +102,7 @@ export class BuyGlideraPage {
price.qty = this.amount; price.qty = this.amount;
} }
this.glideraProvider.buyPrice(this.token, price, (err, buy) => { this.glideraProvider.buyPrice(this.token, price, (err, buy) => {
this.onGoingProcessProvider.set('connectingGlidera', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
@ -139,16 +139,16 @@ export class BuyGlideraPage {
let cancelText = 'Cancel'; let cancelText = 'Cancel';
this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok) => { this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok) => {
if (!ok) return; if (!ok) return;
this.onGoingProcessProvider.set('buyingBitcoin', true); this.onGoingProcessProvider.set('buyingBitcoin');
this.glideraProvider.get2faCode(this.token, (err, tfa) => { this.glideraProvider.get2faCode(this.token, (err, tfa) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
this.ask2FaCode(tfa.mode, (twoFaCode) => { this.ask2FaCode(tfa.mode, (twoFaCode) => {
if (tfa.mode != 'NONE' && _.isEmpty(twoFaCode)) { if (tfa.mode != 'NONE' && _.isEmpty(twoFaCode)) {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError('No code entered'); this.showError('No code entered');
return; return;
} }
@ -162,13 +162,13 @@ export class BuyGlideraPage {
ip: null ip: null
}; };
this.glideraProvider.buy(this.token, twoFaCode, data, (err, data) => { this.glideraProvider.buy(this.token, twoFaCode, data, (err, data) => {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
if (err) return this.showError(err); if (err) return this.showError(err);
this.logger.info(data); this.logger.info(data);
this.openFinishModal(); this.openFinishModal();
}); });
}).catch(() => { }).catch(() => {
this.onGoingProcessProvider.set('buyingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
}); });
}); });

View File

@ -55,9 +55,9 @@ export class GlideraPage {
} }
private init(): void { private init(): void {
this.onGoingProcessProvider.set('connectingGlidera', true); this.onGoingProcessProvider.set('connectingGlidera');
this.glideraProvider.init((err, data) => { this.glideraProvider.init((err, data) => {
this.onGoingProcessProvider.set('connectingGlidera', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.popupProvider.ionicAlert('Error connecting Glidera', err + '. Please re-connect to Glidera'); this.popupProvider.ionicAlert('Error connecting Glidera', err + '. Please re-connect to Glidera');
return; return;
@ -81,9 +81,9 @@ export class GlideraPage {
} }
public submitOauthCode(code?: string): void { public submitOauthCode(code?: string): void {
this.onGoingProcessProvider.set('connectingGlidera', true); this.onGoingProcessProvider.set('connectingGlidera');
this.glideraProvider.authorize(code, (err, data) => { this.glideraProvider.authorize(code, (err, data) => {
this.onGoingProcessProvider.set('connectingGlidera', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.popupProvider.ionicAlert('Authorization error', err); this.popupProvider.ionicAlert('Authorization error', err);
return; return;

View File

@ -91,10 +91,10 @@ export class SellGlideraPage {
} }
private processPaymentInfo(): void { private processPaymentInfo(): void {
this.onGoingProcessProvider.set('connectingGlidera', true); this.onGoingProcessProvider.set('connectingGlidera');
this.glideraProvider.init((err, data) => { this.glideraProvider.init((err, data) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('connectingGlidera', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
} }
@ -106,7 +106,7 @@ export class SellGlideraPage {
price.qty = this.amount; price.qty = this.amount;
} }
this.glideraProvider.sellPrice(this.token, price, (err, sell) => { this.glideraProvider.sellPrice(this.token, price, (err, sell) => {
this.onGoingProcessProvider.set('connectingGlidera', false); this.onGoingProcessProvider.clear();
if (err) { if (err) {
this.showErrorAndBack(err); this.showErrorAndBack(err);
return; return;
@ -143,16 +143,16 @@ export class SellGlideraPage {
let cancelText = 'Cancel'; let cancelText = 'Cancel';
this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok) => { this.popupProvider.ionicConfirm(null, message, okText, cancelText).then((ok) => {
if (!ok) return; if (!ok) return;
this.onGoingProcessProvider.set('sellingBitcoin', true); this.onGoingProcessProvider.set('sellingBitcoin');
this.glideraProvider.get2faCode(this.token, (err, tfa) => { this.glideraProvider.get2faCode(this.token, (err, tfa) => {
if (err) { if (err) {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
this.ask2FaCode(tfa.mode, (twoFaCode) => { this.ask2FaCode(tfa.mode, (twoFaCode) => {
if (tfa.mode != 'NONE' && _.isEmpty(twoFaCode)) { if (tfa.mode != 'NONE' && _.isEmpty(twoFaCode)) {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError('No code entered'); this.showError('No code entered');
return; return;
} }
@ -164,13 +164,13 @@ export class SellGlideraPage {
this.walletProvider.getAddress(this.wallet, false).then((refundAddress) => { this.walletProvider.getAddress(this.wallet, false).then((refundAddress) => {
if (!refundAddress) { if (!refundAddress) {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError('Could not create address'); this.showError('Could not create address');
return; return;
} }
this.glideraProvider.getSellAddress(this.token, (err, sellAddress) => { this.glideraProvider.getSellAddress(this.token, (err, sellAddress) => {
if (!sellAddress || err) { if (!sellAddress || err) {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
return; return;
} }
@ -213,28 +213,28 @@ export class SellGlideraPage {
ip: null ip: null
}; };
this.glideraProvider.sell(this.token, twoFaCode, data, (err, data) => { this.glideraProvider.sell(this.token, twoFaCode, data, (err, data) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
if (err) return this.showError(err); if (err) return this.showError(err);
this.logger.info(data); this.logger.info(data);
this.openFinishModal(); this.openFinishModal();
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
this.walletProvider.removeTx(this.wallet, publishedTxp).catch((err) => { // TODO in the original code use signedTxp on this function this.walletProvider.removeTx(this.wallet, publishedTxp).catch((err) => { // TODO in the original code use signedTxp on this function
if (err) this.logger.debug(err); if (err) this.logger.debug(err);
}); });
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('sellingBitcoin', false); this.onGoingProcessProvider.clear();
this.showError(err); this.showError(err);
}); });
}); });

View File

@ -146,10 +146,11 @@ export class BuyMercadoLibrePage {
this.logger.info(err); this.logger.info(err);
return reject(err); return reject(err);
} }
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => { this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
return resolve(txp); return resolve(txp);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
return reject(err); return reject(err);
}); });
}); });
@ -296,7 +297,7 @@ export class BuyMercadoLibrePage {
} }
this.mercadoLibreProvider.savePendingGiftCard(newData, null, (err: any) => { this.mercadoLibreProvider.savePendingGiftCard(newData, null, (err: any) => {
this.onGoingProcessProvider.set('Comprando Vale-Presente', false); this.onGoingProcessProvider.clear();
this.logger.debug("Saved new gift card with status: " + newData.status); this.logger.debug("Saved new gift card with status: " + newData.status);
this.mlGiftCard = newData; this.mlGiftCard = newData;
this.openFinishModal(); this.openFinishModal();
@ -317,7 +318,7 @@ export class BuyMercadoLibrePage {
uuid: wallet.id, uuid: wallet.id,
email email
}; };
this.onGoingProcessProvider.set('loadingTxInfo', true); this.onGoingProcessProvider.set('loadingTxInfo');
this.createInvoice(dataSrc).then((data: any) => { this.createInvoice(dataSrc).then((data: any) => {
let invoice = data.invoice; let invoice = data.invoice;
let accessKey = data.accessKey; let accessKey = data.accessKey;
@ -329,7 +330,7 @@ export class BuyMercadoLibrePage {
this.message = this.amountUnitStr + " for Mercado Livre Brazil Gift Card"; // TODO: translate this.message = this.amountUnitStr + " for Mercado Livre Brazil Gift Card"; // TODO: translate
this.createTx(wallet, invoice, this.message).then((ctxp: any) => { this.createTx(wallet, invoice, this.message).then((ctxp: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
// Save in memory // Save in memory
@ -352,13 +353,13 @@ export class BuyMercadoLibrePage {
this.setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee); this.setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
this._resetValues(); this._resetValues();
this.showError(err.title, err.message); this.showError(err.title, err.message);
return; return;
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err.title, err.message); this.showErrorAndBack(err.title, err.message);
return; return;
}); });
@ -376,7 +377,7 @@ export class BuyMercadoLibrePage {
} }
this.publishAndSign(this.wallet, this.createdTx).then((txSent) => { this.publishAndSign(this.wallet, this.createdTx).then((txSent) => {
this.onGoingProcessProvider.set('Comprando Vale-Presente', true); this.onGoingProcessProvider.set('Comprando Vale-Presente');
this.checkTransaction(1, this.createdTx.giftData); this.checkTransaction(1, this.createdTx.giftData);
}).catch((err: any) => { }).catch((err: any) => {
this._resetValues(); this._resetValues();

View File

@ -146,8 +146,11 @@ export class ShapeshiftConfirmPage {
} }
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => { this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
return resolve(txp); return resolve(txp);
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
return reject(err); return reject(err);
}); });
}); });
@ -260,7 +263,7 @@ export class ShapeshiftConfirmPage {
} }
private createShift(): void { private createShift(): void {
this.onGoingProcessProvider.set('connectingShapeshift', true); this.onGoingProcessProvider.set('connectingShapeshift');
this.walletProvider.getAddress(this.toWallet, false).then((withdrawalAddress: string) => { this.walletProvider.getAddress(this.toWallet, false).then((withdrawalAddress: string) => {
withdrawalAddress = this.getLegacyAddressFormat(withdrawalAddress, this.toWallet.coin); withdrawalAddress = this.getLegacyAddressFormat(withdrawalAddress, this.toWallet.coin);
@ -275,7 +278,7 @@ export class ShapeshiftConfirmPage {
} }
this.shapeshiftProvider.shift(data, (err: any, shapeData: any) => { this.shapeshiftProvider.shift(data, (err: any, shapeData: any) => {
if (err || shapeData.error) { if (err || shapeData.error) {
this.onGoingProcessProvider.set('connectingShapeshift', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(null, err || shapeData.error); this.showErrorAndBack(null, err || shapeData.error);
return; return;
} }
@ -288,7 +291,7 @@ export class ShapeshiftConfirmPage {
this.shapeInfo = shapeData; this.shapeInfo = shapeData;
this.shapeshiftProvider.getRate(this.getCoinPair(), (err: any, r: any) => { this.shapeshiftProvider.getRate(this.getCoinPair(), (err: any, r: any) => {
this.onGoingProcessProvider.set('connectingShapeshift', false); this.onGoingProcessProvider.clear();
this.rateUnit = r.rate; this.rateUnit = r.rate;
let amountUnit = this.txFormatProvider.satToUnit(ctxp.amount); let amountUnit = this.txFormatProvider.satToUnit(ctxp.amount);
let withdrawalSat = Number((this.rateUnit * amountUnit * 100000000).toFixed()); let withdrawalSat = Number((this.rateUnit * amountUnit * 100000000).toFixed());
@ -307,18 +310,18 @@ export class ShapeshiftConfirmPage {
this.setFiatTotalAmount(ctxp.amount, ctxp.fee, withdrawalSat); this.setFiatTotalAmount(ctxp.amount, ctxp.fee, withdrawalSat);
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('connectingShapeshift', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(err.title, err.message); this.showErrorAndBack(err.title, err.message);
return; return;
}); });
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('connectingShapeshift', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(null, 'Could not get address'); this.showErrorAndBack(null, 'Could not get address');
return; return;
}); });
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('connectingShapeshift', false); this.onGoingProcessProvider.clear();
this.showErrorAndBack(null, 'Could not get address'); this.showErrorAndBack(null, 'Could not get address');
return; return;
}); });

View File

@ -66,9 +66,9 @@ export class TourPage {
} }
public createDefaultWallet(): void { public createDefaultWallet(): void {
this.onGoingProcessProvider.set('creatingWallet', true); this.onGoingProcessProvider.set('creatingWallet');
this.profileProvider.createDefaultWallet().then((wallet) => { this.profileProvider.createDefaultWallet().then((wallet) => {
this.onGoingProcessProvider.set('creatingWallet', false); this.onGoingProcessProvider.clear();
this.navCtrl.push(CollectEmailPage, { walletId: wallet.id }); this.navCtrl.push(CollectEmailPage, { walletId: wallet.id });
}) })
} }

View File

@ -114,9 +114,9 @@ export class PaperWalletPage {
} }
public scanFunds() { public scanFunds() {
this.onGoingProcessProvider.set('scanning', true); this.onGoingProcessProvider.set('scanning');
this._scanFunds().then((data) => { this._scanFunds().then((data) => {
this.onGoingProcessProvider.set('scanning', false); this.onGoingProcessProvider.clear();
this.privateKey = data.privateKey; this.privateKey = data.privateKey;
this.balanceSat = data.balance; this.balanceSat = data.balance;
if (this.balanceSat <= 0) { if (this.balanceSat <= 0) {
@ -124,7 +124,7 @@ export class PaperWalletPage {
this.navCtrl.pop(); this.navCtrl.pop();
} }
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('scanning', false); this.onGoingProcessProvider.clear();
this.logger.error(err); this.logger.error(err);
this.popupProvider.ionicAlert(this.translate.instant('Error scanning funds:'), err || err.toString()); this.popupProvider.ionicAlert(this.translate.instant('Error scanning funds:'), err || err.toString());
this.navCtrl.pop(); this.navCtrl.pop();
@ -159,9 +159,9 @@ export class PaperWalletPage {
} }
public sweepWallet(): void { public sweepWallet(): void {
this.onGoingProcessProvider.set('sweepingWallet', true); this.onGoingProcessProvider.set('sweepingWallet');
this._sweepWallet().then((data: any) => { this._sweepWallet().then((data: any) => {
this.onGoingProcessProvider.set('sweepingWallet', false); this.onGoingProcessProvider.clear();
this.logger.debug('Success sweep. Destination address:' + data.destinationAddress + ' - transaction id: ' + data.txid); this.logger.debug('Success sweep. Destination address:' + data.destinationAddress + ' - transaction id: ' + data.txid);
this.openFinishModal(); this.openFinishModal();
}).catch((err: any) => { }).catch((err: any) => {

View File

@ -301,7 +301,7 @@ export class ConfirmPage {
return resolve(); return resolve();
} }
this.onGoingProcessProvider.set('calculatingFee', true); this.onGoingProcessProvider.set('calculatingFee');
this.feeProvider.getFeeRate(wallet.coin, tx.network, tx.feeLevel).then((feeRate: any) => { this.feeProvider.getFeeRate(wallet.coin, tx.network, tx.feeLevel).then((feeRate: any) => {
if (!this.usingCustomFee) tx.feeRate = feeRate; if (!this.usingCustomFee) tx.feeRate = feeRate;
@ -401,7 +401,7 @@ export class ConfirmPage {
if (!tx.sendMax) return resolve(); if (!tx.sendMax) return resolve();
this.onGoingProcessProvider.set('retrievingInputs', true); this.onGoingProcessProvider.set('retrievingInputs');
this.walletProvider.getSendMaxInfo(wallet, { this.walletProvider.getSendMaxInfo(wallet, {
feePerKb: tx.feeRate, feePerKb: tx.feeRate,
excludeUnconfirmedUtxos: !tx.spendUnconfirmed, excludeUnconfirmedUtxos: !tx.spendUnconfirmed,
@ -528,7 +528,7 @@ export class ConfirmPage {
return; return;
} }
this.onGoingProcessProvider.set('creatingTx', true); this.onGoingProcessProvider.set('creatingTx');
this.getTxp(_.clone(tx), wallet, false).then((txp: any) => { this.getTxp(_.clone(tx), wallet, false).then((txp: any) => {
// confirm txs for more that 20usd, if not spending/touchid is enabled // confirm txs for more that 20usd, if not spending/touchid is enabled
@ -558,6 +558,7 @@ export class ConfirmPage {
let publishAndSign = (): void => { let publishAndSign = (): void => {
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
this.logger.info('No signing proposal: No private key'); this.logger.info('No signing proposal: No private key');
this.onGoingProcessProvider.set('sendingTx');
this.walletProvider.onlyPublish(wallet, txp).then(() => { this.walletProvider.onlyPublish(wallet, txp).then(() => {
this.onGoingProcessProvider.clear(); this.onGoingProcessProvider.clear();
this.openFinishModal(true); this.openFinishModal(true);
@ -569,6 +570,7 @@ export class ConfirmPage {
} }
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => { this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
if (this.config.confirmedTxsNotifications && this.config.confirmedTxsNotifications.enabled) { if (this.config.confirmedTxsNotifications && this.config.confirmedTxsNotifications.enabled) {
this.txConfirmNotificationProvider.subscribe(wallet, { this.txConfirmNotificationProvider.subscribe(wallet, {
txid: txp.txid txid: txp.txid
@ -576,6 +578,7 @@ export class ConfirmPage {
} }
this.openFinishModal(); this.openFinishModal();
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
this.setSendError(err); this.setSendError(err);
return; return;
}); });

View File

@ -164,7 +164,7 @@ export class BitcoinCashPage {
this.walletProvider.getKeys(wallet).then((keys) => { this.walletProvider.getKeys(wallet).then((keys) => {
opts.extendedPrivateKey = keys.xPrivKey; opts.extendedPrivateKey = keys.xPrivKey;
this.onGoingProcessProvider.set('duplicatingWallet', true); this.onGoingProcessProvider.set('duplicatingWallet');
importOrCreate().then((result: any) => { importOrCreate().then((result: any) => {
let newWallet = result.newWallet; let newWallet = result.newWallet;
let isNew = result.isNew; let isNew = result.isNew;
@ -173,7 +173,7 @@ export class BitcoinCashPage {
this.pushNotificationsProvider.updateSubscription(newWallet); this.pushNotificationsProvider.updateSubscription(newWallet);
addCopayers(newWallet, isNew, (err) => { addCopayers(newWallet, isNew, (err) => {
this.onGoingProcessProvider.set('duplicatingWallet', false); this.onGoingProcessProvider.clear();
if (err) return setErr(err); if (err) return setErr(err);
if (isNew) if (isNew)
@ -184,7 +184,7 @@ export class BitcoinCashPage {
}); });
}); });
}).catch((err) => { }).catch((err) => {
this.onGoingProcessProvider.set('duplicatingWallet', false); this.onGoingProcessProvider.clear();
setErr(err); setErr(err);
}); });
}).catch((err) => { }).catch((err) => {

View File

@ -57,9 +57,9 @@ export class AllAddressesPage {
} }
public sendByEmail(): any { public sendByEmail(): any {
this.onGoingProcessProvider.set('sendingByEmail', true); this.onGoingProcessProvider.set('sendingByEmail');
setTimeout(() => { setTimeout(() => {
this.onGoingProcessProvider.set('sendingByEmail', false); this.onGoingProcessProvider.clear();
let appName = this.appProvider.info.nameCase; let appName = this.appProvider.info.nameCase;
let body: string = appName + ' Wallet "' + this.walletName + '" Addresses\n Only Main Addresses are shown.\n\n'; let body: string = appName + ' Wallet "' + this.walletName + '" Addresses\n Only Main Addresses are shown.\n\n';

View File

@ -121,10 +121,10 @@ export class WalletAddressesPage {
public newAddress(): void { public newAddress(): void {
if (this.gapReached) return; if (this.gapReached) return;
this.onGoingProcessProvider.set('generatingNewAddress', true); this.onGoingProcessProvider.set('generatingNewAddress');
this.walletProvider.getAddress(this.wallet, true).then((addr: string) => { this.walletProvider.getAddress(this.wallet, true).then((addr: string) => {
this.walletProvider.getMainAddresses(this.wallet, { limit: 1 }).then((_addr: any) => { this.walletProvider.getMainAddresses(this.wallet, { limit: 1 }).then((_addr: any) => {
this.onGoingProcessProvider.set('generatingNewAddress', false); this.onGoingProcessProvider.clear();
if (addr != _addr[0].address) { if (addr != _addr[0].address) {
this.popupProvider.ionicAlert(this.translate.instant('Error'), this.translate.instant('New address could not be generated. Please try again.')); this.popupProvider.ionicAlert(this.translate.instant('Error'), this.translate.instant('New address could not be generated. Please try again.'));
return; return;
@ -134,12 +134,12 @@ export class WalletAddressesPage {
this.viewAll = this.noBalance.length > this.UNUSED_ADDRESS_LIMIT; this.viewAll = this.noBalance.length > this.UNUSED_ADDRESS_LIMIT;
}).catch((err) => { }).catch((err) => {
this.logger.error(err); this.logger.error(err);
this.onGoingProcessProvider.set('generatingNewAddress', false); this.onGoingProcessProvider.clear();
this.popupProvider.ionicAlert(this.translate.instant('Error'), err); this.popupProvider.ionicAlert(this.translate.instant('Error'), err);
}); });
}).catch((err) => { }).catch((err) => {
this.logger.error(err); this.logger.error(err);
this.onGoingProcessProvider.set('generatingNewAddress', false); this.onGoingProcessProvider.clear();
if (err.toString().match('MAIN_ADDRESS_GAP_REACHED')) { if (err.toString().match('MAIN_ADDRESS_GAP_REACHED')) {
this.gapReached = true; this.gapReached = true;
} else { } else {

View File

@ -50,10 +50,10 @@ export class WalletDeletePage {
}; };
public deleteWallet(): void { public deleteWallet(): void {
this.onGoingProcessProvider.set('deletingWallet', true); this.onGoingProcessProvider.set('deletingWallet');
this.profileProvider.deleteWalletClient(this.wallet).then(() => { this.profileProvider.deleteWalletClient(this.wallet).then(() => {
this.events.publish('status:updated'); this.events.publish('status:updated');
this.onGoingProcessProvider.set('deletingWallet', false); this.onGoingProcessProvider.clear();
this.pushNotificationsProvider.unsubscribe(this.wallet); this.pushNotificationsProvider.unsubscribe(this.wallet);
this.navCtrl.popToRoot({ animate: false }).then(() => { this.navCtrl.popToRoot({ animate: false }).then(() => {
this.navCtrl.parent.select(0); this.navCtrl.parent.select(0);

View File

@ -146,9 +146,9 @@ export class TxDetailsPage {
private updateTx(opts?: any): void { private updateTx(opts?: any): void {
opts = opts ? opts : {}; opts = opts ? opts : {};
if (!opts.hideLoading) this.onGoingProcess.set('loadingTxInfo', true); if (!opts.hideLoading) this.onGoingProcess.set('loadingTxInfo');
this.walletProvider.getTx(this.wallet, this.txId).then((tx: any) => { this.walletProvider.getTx(this.wallet, this.txId).then((tx: any) => {
if (!opts.hideLoading) this.onGoingProcess.set('loadingTxInfo', false); if (!opts.hideLoading) this.onGoingProcess.clear();
this.btx = this.txFormatProvider.processTx(this.wallet.coin, tx, this.walletProvider.useLegacyAddress()); this.btx = this.txFormatProvider.processTx(this.wallet.coin, tx, this.walletProvider.useLegacyAddress());
let v: string = this.txFormatProvider.formatAlternativeStr(this.wallet.coin, tx.fees); let v: string = this.txFormatProvider.formatAlternativeStr(this.wallet.coin, tx.fees);
@ -173,7 +173,7 @@ export class TxDetailsPage {
return; return;
}); });
}).catch((err: any) => { }).catch((err: any) => {
if (!opts.hideLoading) this.onGoingProcess.set('loadingTxInfo', false); if (!opts.hideLoading) this.onGoingProcess.clear();
this.logger.warn('Error getting transaction: ' + err); this.logger.warn('Error getting transaction: ' + err);
this.navCtrl.pop(); this.navCtrl.pop();
return this.popupProvider.ionicAlert('Error', this.translate.instant('Transaction not available at this time')); return this.popupProvider.ionicAlert('Error', this.translate.instant('Transaction not available at this time'));

View File

@ -202,8 +202,10 @@ export class TxpDetailsPage {
public sign(): void { public sign(): void {
this.loading = true; this.loading = true;
this.walletProvider.publishAndSign(this.wallet, this.tx).then((txp: any) => { this.walletProvider.publishAndSign(this.wallet, this.tx).then((txp: any) => {
this.onGoingProcessProvider.clear();
this.openFinishModal(); this.openFinishModal();
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
this.setError(err, ('Could not send payment')); this.setError(err, ('Could not send payment'));
}); });
} }
@ -214,9 +216,12 @@ export class TxpDetailsPage {
this.popupProvider.ionicConfirm(title, msg, null, null).then((res: boolean) => { this.popupProvider.ionicConfirm(title, msg, null, null).then((res: boolean) => {
if (!res) return if (!res) return
this.loading = true; this.loading = true;
this.onGoingProcessProvider.set('rejectTx');
this.walletProvider.reject(this.wallet, this.tx).then((txpr) => { this.walletProvider.reject(this.wallet, this.tx).then((txpr) => {
this.onGoingProcessProvider.clear();
this.close(); this.close();
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.clear();
this.setError(err, this.translate.instant('Could not reject payment')); this.setError(err, this.translate.instant('Could not reject payment'));
}); });
}); });
@ -227,12 +232,12 @@ export class TxpDetailsPage {
let msg = this.translate.instant('Are you sure you want to remove this transaction?'); let msg = this.translate.instant('Are you sure you want to remove this transaction?');
this.popupProvider.ionicConfirm(title, msg, null, null).then((res: boolean) => { this.popupProvider.ionicConfirm(title, msg, null, null).then((res: boolean) => {
if (!res) return; if (!res) return;
this.onGoingProcessProvider.set('removeTx', true); this.onGoingProcessProvider.set('removeTx');
this.walletProvider.removeTx(this.wallet, this.tx).then(() => { this.walletProvider.removeTx(this.wallet, this.tx).then(() => {
this.onGoingProcessProvider.set('removeTx', false); this.onGoingProcessProvider.clear();
this.close(); this.close();
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('removeTx', false); this.onGoingProcessProvider.clear();
if (err && !(err.message && err.message.match(/Unexpected/))) { if (err && !(err.message && err.message.match(/Unexpected/))) {
this.setError(err, this.translate.instant('Could not delete payment proposal')); this.setError(err, this.translate.instant('Could not delete payment proposal'));
} }
@ -242,12 +247,12 @@ export class TxpDetailsPage {
public broadcast(txp: any): void { public broadcast(txp: any): void {
this.loading = true; this.loading = true;
this.onGoingProcessProvider.set('broadcastingTx', true); this.onGoingProcessProvider.set('broadcastingTx');
this.walletProvider.broadcastTx(this.wallet, this.tx).then((txpb: any) => { this.walletProvider.broadcastTx(this.wallet, this.tx).then((txpb: any) => {
this.onGoingProcessProvider.set('broadcastingTx', false); this.onGoingProcessProvider.clear();
this.openFinishModal(); this.openFinishModal();
}).catch((err: any) => { }).catch((err: any) => {
this.onGoingProcessProvider.set('broadcastingTx', false); this.onGoingProcessProvider.clear();
this.setError(err, 'Could not broadcast payment'); this.setError(err, 'Could not broadcast payment');
}); });
} }

View File

@ -9,6 +9,7 @@ import { BwcErrorProvider } from '../../providers/bwc-error/bwc-error';
import { ProfileProvider } from '../../providers/profile/profile'; import { ProfileProvider } from '../../providers/profile/profile';
import { TimeProvider } from '../../providers/time/time'; import { TimeProvider } from '../../providers/time/time';
import { WalletProvider } from '../../providers/wallet/wallet'; import { WalletProvider } from '../../providers/wallet/wallet';
import { OnGoingProcessProvider } from '../../providers/on-going-process/on-going-process';
// pages // pages
import { BackupWarningPage } from '../../pages/backup/backup-warning/backup-warning'; import { BackupWarningPage } from '../../pages/backup/backup-warning/backup-warning';
@ -52,7 +53,8 @@ export class WalletDetailsPage {
private events: Events, private events: Events,
private logger: Logger, private logger: Logger,
private timeProvider: TimeProvider, private timeProvider: TimeProvider,
private translate: TranslateService private translate: TranslateService,
private onGoingProcessProvider: OnGoingProcessProvider
) { ) {
let clearCache = this.navParams.data.clearCache; let clearCache = this.navParams.data.clearCache;
this.wallet = this.profileProvider.getWallet(this.navParams.data.walletId); this.wallet = this.profileProvider.getWallet(this.navParams.data.walletId);
@ -196,12 +198,17 @@ export class WalletDetailsPage {
}; };
public recreate() { public recreate() {
this.onGoingProcessProvider.set('recreating');
this.walletProvider.recreate(this.wallet).then(() => { this.walletProvider.recreate(this.wallet).then(() => {
this.onGoingProcessProvider.clear();
setTimeout(() => { setTimeout(() => {
this.walletProvider.startScan(this.wallet).then(() => { this.walletProvider.startScan(this.wallet).then(() => {
this.updateAll(true); this.updateAll(true);
}); });
}); });
}).catch((err) => {
this.onGoingProcessProvider.clear();
this.logger.error(err);
}); });
}; };

View File

@ -59,11 +59,11 @@ export class OnGoingProcessProvider {
'topup': this.translate.instant('Top up in progress...'), 'topup': this.translate.instant('Top up in progress...'),
'duplicatingWallet': this.translate.instant('Duplicating wallet...'), 'duplicatingWallet': this.translate.instant('Duplicating wallet...'),
}; };
this.ongoingProcess = {}; this.ongoingProcess = [];
} }
public clear() { public clear() {
this.ongoingProcess = {}; this.ongoingProcess = [];
this.loading.dismiss(); this.loading.dismiss();
this.loading = null; this.loading = null;
this.logger.debug('ongoingProcess clear'); this.logger.debug('ongoingProcess clear');
@ -76,29 +76,21 @@ export class OnGoingProcessProvider {
public resume(): void { public resume(): void {
this.ongoingProcess = this.pausedOngoingProcess; this.ongoingProcess = this.pausedOngoingProcess;
_.forEach(this.pausedOngoingProcess, (v, k) => { _.forEach(this.pausedOngoingProcess, (v) => {
this.set(k, v); this.set(v);
return; return;
}); });
this.pausedOngoingProcess = {}; this.pausedOngoingProcess = [];
} }
public set(processName: string, isOn: boolean): void { public set(processName: string): void {
this.logger.debug('ongoingProcess', processName, isOn); this.logger.debug('ongoingProcess active: ', processName);
this.ongoingProcess[processName] = isOn; this.ongoingProcess.push(processName);
let showName = this.processNames[processName] || processName; let showName = this.processNames[processName] || processName;
if (!isOn) { if (!this.loading) {
delete (this.ongoingProcess[processName]); this.loading = this.loadingCtrl.create();
if (_.isEmpty(this.ongoingProcess)) {
this.loading.dismiss();
this.loading = null;
}
} else {
if (!this.loading) {
this.loading = this.loadingCtrl.create();
}
this.loading.setContent(showName);
this.loading.present();
} }
this.loading.setContent(showName);
this.loading.present();
} }
} }

View File

@ -28,12 +28,12 @@ export class PayproProvider {
this.logger.debug('Fetch PayPro Request...', uri); this.logger.debug('Fetch PayPro Request...', uri);
if (!disableLoader) this.onGoingProcessProvider.set('fetchingPayPro', true); if (!disableLoader) this.onGoingProcessProvider.set('fetchingPayPro');
wallet.fetchPayPro({ wallet.fetchPayPro({
payProUrl: uri, payProUrl: uri,
}, (err, paypro) => { }, (err, paypro) => {
if (!disableLoader) this.onGoingProcessProvider.set('fetchingPayPro', false); if (!disableLoader) this.onGoingProcessProvider.clear();
if (err) return reject(err); if (err) return reject(err);
else if (!paypro.verified) { else if (!paypro.verified) {
this.logger.warn('Failed to verify payment protocol signatures'); this.logger.warn('Failed to verify payment protocol signatures');

View File

@ -49,7 +49,7 @@ export class WalletProvider {
private rateProvider: RateProvider, private rateProvider: RateProvider,
private filter: FilterProvider, private filter: FilterProvider,
private popupProvider: PopupProvider, private popupProvider: PopupProvider,
private ongoingProcessProvider: OnGoingProcessProvider, private onGoingProcessProvider: OnGoingProcessProvider,
private touchidProvider: TouchIdProvider, private touchidProvider: TouchIdProvider,
private events: Events, private events: Events,
private feeProvider: FeeProvider, private feeProvider: FeeProvider,
@ -979,10 +979,8 @@ export class WalletProvider {
public recreate(wallet: any): Promise<any> { public recreate(wallet: any): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.logger.debug('Recreating wallet:', wallet.id); this.logger.debug('Recreating wallet:', wallet.id);
this.ongoingProcessProvider.set('recreating', true);
wallet.recreateWallet((err: any) => { wallet.recreateWallet((err: any) => {
wallet.notAuthorized = false; wallet.notAuthorized = false;
this.ongoingProcessProvider.set('recreating', false);
if (err) return reject(err); if (err) return reject(err);
return resolve(); return resolve();
}); });
@ -1141,14 +1139,11 @@ export class WalletProvider {
public reject(wallet: any, txp: any): Promise<any> { public reject(wallet: any, txp: any): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.ongoingProcessProvider.set('rejectTx', true);
this.rejectTx(wallet, txp).then((txpr: any) => { this.rejectTx(wallet, txp).then((txpr: any) => {
this.invalidateCache(wallet); this.invalidateCache(wallet);
this.ongoingProcessProvider.set('rejectTx', false);
this.events.publish('Local/TxAction', wallet.id); this.events.publish('Local/TxAction', wallet.id);
return resolve(txpr); return resolve(txpr);
}).catch((err) => { }).catch((err) => {
this.ongoingProcessProvider.set('rejectTx', false);
return reject(err); return reject(err);
}); });
}); });
@ -1156,7 +1151,6 @@ export class WalletProvider {
public onlyPublish(wallet: any, txp: any): Promise<any> { public onlyPublish(wallet: any, txp: any): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.ongoingProcessProvider.set('sendingTx', true);
this.publishTx(wallet, txp).then((publishedTxp) => { this.publishTx(wallet, txp).then((publishedTxp) => {
this.invalidateCache(wallet); this.invalidateCache(wallet);
this.events.publish('Local/TxAction', wallet.id); this.events.publish('Local/TxAction', wallet.id);
@ -1184,26 +1178,22 @@ export class WalletProvider {
private signAndBroadcast(wallet: any, publishedTxp: any, password: any): Promise<any> { private signAndBroadcast(wallet: any, publishedTxp: any, password: any): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.ongoingProcessProvider.set('signingTx', true); this.onGoingProcessProvider.set('signingTx');
this.signTx(wallet, publishedTxp, password).then((signedTxp: any) => { this.signTx(wallet, publishedTxp, password).then((signedTxp: any) => {
this.invalidateCache(wallet); this.invalidateCache(wallet);
if (signedTxp.status == 'accepted') { if (signedTxp.status == 'accepted') {
this.ongoingProcessProvider.set('broadcastingTx', true); this.onGoingProcessProvider.set('broadcastingTx');
this.broadcastTx(wallet, signedTxp).then((broadcastedTxp: any) => { this.broadcastTx(wallet, signedTxp).then((broadcastedTxp: any) => {
this.ongoingProcessProvider.clear();
this.events.publish('Local/TxAction', wallet.id); this.events.publish('Local/TxAction', wallet.id);
return resolve(broadcastedTxp); return resolve(broadcastedTxp);
}).catch((err) => { }).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err)); return reject(this.bwcErrorProvider.msg(err));
}); });
} else { } else {
this.ongoingProcessProvider.clear();
this.events.publish('Local/TxAction', wallet.id); this.events.publish('Local/TxAction', wallet.id);
return resolve(signedTxp); return resolve(signedTxp);
}; };
}).catch((err) => { }).catch((err) => {
this.ongoingProcessProvider.clear();
this.logger.warn('sign error:' + err); this.logger.warn('sign error:' + err);
let msg = err && err.message ? err.message : this.translate.instant('The payment was created but could not be completed. Please try again from home screen'); let msg = err && err.message ? err.message : this.translate.instant('The payment was created but could not be completed. Please try again from home screen');
this.events.publish('Local/TxAction', wallet.id); this.events.publish('Local/TxAction', wallet.id);
@ -1223,12 +1213,11 @@ export class WalletProvider {
return reject(err); return reject(err);
}); });
}).catch((err) => { }).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err)); return reject(this.bwcErrorProvider.msg(err));
}); });
} else { } else {
this.prepare(wallet).then((password: string) => { this.prepare(wallet).then((password: string) => {
this.ongoingProcessProvider.set('sendingTx', true); this.onGoingProcessProvider.set('sendingTx');
this.publishTx(wallet, txp).then((publishedTxp: any) => { this.publishTx(wallet, txp).then((publishedTxp: any) => {
this.signAndBroadcast(wallet, publishedTxp, password).then((broadcastedTxp: any) => { this.signAndBroadcast(wallet, publishedTxp, password).then((broadcastedTxp: any) => {
return resolve(broadcastedTxp); return resolve(broadcastedTxp);
@ -1236,11 +1225,9 @@ export class WalletProvider {
return reject(err); return reject(err);
}); });
}).catch((err) => { }).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err)); return reject(this.bwcErrorProvider.msg(err));
}); });
}).catch((err) => { }).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err)); return reject(this.bwcErrorProvider.msg(err));
}); });
}; };