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 {
this.onGoingProcessProvider.set('deletingWallet', true);
this.onGoingProcessProvider.set('deletingWallet');
this.profileProvider.deleteWalletClient(this.wallet).then(() => {
this.onGoingProcessProvider.set('deletingWallet', false);
this.onGoingProcessProvider.clear();
this.pushNotificationsProvider.unsubscribe(this.wallet);
this.navCtrl.popToRoot().then(() => {
this.navCtrl.parent.select(0);
});
}).catch((err: any) => {
this.onGoingProcessProvider.set('deletingWallet', false);
this.onGoingProcessProvider.clear();
let errorText = this.translate.instant('Error');
this.popupProvider.ionicAlert(errorText, err.message || err);
});

View File

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

View File

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

View File

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

View File

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

View File

@ -98,10 +98,10 @@ export class SendFeedbackPage {
"deviceVersion": versionStr
};
if (!goHome) this.onGoingProcessProvider.set('sendingFeedback', true);
if (!goHome) this.onGoingProcessProvider.set('sendingFeedback');
this.feedbackProvider.send(dataSrc).then(() => {
if (goHome) return;
this.onGoingProcessProvider.set('sendingFeedback', false);
this.onGoingProcessProvider.clear();
if (!this.score) {
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.');
@ -116,7 +116,7 @@ export class SendFeedbackPage {
}
}).catch((err) => {
if (goHome) return;
this.onGoingProcessProvider.set('sendingFeedback', false);
this.onGoingProcessProvider.clear();
let title = this.translate.instant('Error');
let subtitle = this.translate.instant('Feedback could not be submitted. Please try again later.');
this.popupProvider.ionicAlert(title, subtitle);

View File

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

View File

@ -103,7 +103,7 @@ export class HomePage {
this.zone = new NgZone({ enableLongStackTrace: false });
}
ionViewWillEnter() {
ionViewWillEnter() {
this.config = this.configProvider.get();
this.pushNotificationsProvider.init();
this.homeIntegrations = this.homeIntegrationsProvider.get();
@ -166,7 +166,7 @@ export class HomePage {
private startUpdatingWalletId(walletId: string) {
this.updatingWalletId[walletId] = true;
}
private stopUpdatingWalletId(walletId: string) {
setTimeout(() => {
this.updatingWalletId[walletId] = false;
@ -179,8 +179,8 @@ export class HomePage {
this.walletsBch = this.profileProvider.getWallets({ coin: 'bch' });
this.updateAllWallets();
}, 10000, {
'leading': true
});
'leading': true
});
public checkHomeTip(): void {
this.persistenceProvider.getHomeTipAccepted().then((value: string) => {
@ -230,7 +230,7 @@ export class HomePage {
this.walletProvider.getStatus(wallet, {}).then((status: any) => {
wallet.status = status;
wallet.error = null;
this.profileProvider.setLastKnownBalance(wallet.id, wallet.status.availableBalanceStr);
this.profileProvider.setLastKnownBalance(wallet.id, wallet.status.availableBalanceStr);
this.updateTxps();
this.stopUpdatingWalletId(walletId);
}).catch((err: any) => {
@ -243,27 +243,27 @@ export class HomePage {
this.profileProvider.getTxps({ limit: 3 }).then((data: any) => {
this.zone.run(() => {
this.txps = data.txps;
this.txpsN = data.n;
this.txpsN = data.n;
});
}).catch((err: any) => {
this.logger.error(err);
});
}, 5000, {
'leading': true
});
'leading': true
});
private getNotifications = _.debounce(() => {
this.profileProvider.getNotifications({ limit: 3 }).then((data: any) => {
this.zone.run(() => {
this.notifications = data.notifications;
this.notificationsN = data.total;
this.notificationsN = data.total;
});
}).catch((err: any) => {
this.logger.error(err);
});
}, 5000, {
'leading': true
});
'leading': true
});
private updateAllWallets(): void {
let wallets: any[] = [];
@ -357,12 +357,13 @@ export class HomePage {
if (txp) {
this.openTxpModal(txp);
} else {
this.onGoingProcessProvider.set('loadingTxInfo', true);
this.onGoingProcessProvider.set('loadingTxInfo');
this.walletProvider.getTxp(wallet, n.txpId).then((txp: any) => {
var _txp = txp;
this.onGoingProcessProvider.set('loadingTxInfo', false);
this.onGoingProcessProvider.clear();
this.openTxpModal(_txp);
}).catch((err: any) => {
this.onGoingProcessProvider.clear();
this.logger.warn('No txp found');
let title = this.translate.instant('Error');
let subtitle = this.translate.instant('Transaction not found');

View File

@ -30,12 +30,12 @@ export class ProposalsPage {
this.addressbook = ab || {};
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.onGoingProcessProvider.set(loading, false);
this.onGoingProcessProvider.clear();
this.txps = txpsData.txps;
}).catch((err: any) => {
this.onGoingProcessProvider.set(loading, false);
this.onGoingProcessProvider.clear();
this.logger.error(err);
});
}).catch((err: any) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -146,10 +146,11 @@ export class BuyMercadoLibrePage {
this.logger.info(err);
return reject(err);
}
this.walletProvider.publishAndSign(wallet, txp).then((txp: any) => {
this.onGoingProcessProvider.clear();
return resolve(txp);
}).catch((err: any) => {
this.onGoingProcessProvider.clear();
return reject(err);
});
});
@ -296,7 +297,7 @@ export class BuyMercadoLibrePage {
}
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.mlGiftCard = newData;
this.openFinishModal();
@ -317,7 +318,7 @@ export class BuyMercadoLibrePage {
uuid: wallet.id,
email
};
this.onGoingProcessProvider.set('loadingTxInfo', true);
this.onGoingProcessProvider.set('loadingTxInfo');
this.createInvoice(dataSrc).then((data: any) => {
let invoice = data.invoice;
let accessKey = data.accessKey;
@ -329,7 +330,7 @@ export class BuyMercadoLibrePage {
this.message = this.amountUnitStr + " for Mercado Livre Brazil Gift Card"; // TODO: translate
this.createTx(wallet, invoice, this.message).then((ctxp: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false);
this.onGoingProcessProvider.clear();
// Save in memory
@ -352,13 +353,13 @@ export class BuyMercadoLibrePage {
this.setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
}).catch((err: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false);
this.onGoingProcessProvider.clear();
this._resetValues();
this.showError(err.title, err.message);
return;
});
}).catch((err: any) => {
this.onGoingProcessProvider.set('loadingTxInfo', false);
this.onGoingProcessProvider.clear();
this.showErrorAndBack(err.title, err.message);
return;
});
@ -376,7 +377,7 @@ export class BuyMercadoLibrePage {
}
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);
}).catch((err: any) => {
this._resetValues();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,9 +57,9 @@ export class AllAddressesPage {
}
public sendByEmail(): any {
this.onGoingProcessProvider.set('sendingByEmail', true);
this.onGoingProcessProvider.set('sendingByEmail');
setTimeout(() => {
this.onGoingProcessProvider.set('sendingByEmail', false);
this.onGoingProcessProvider.clear();
let appName = this.appProvider.info.nameCase;
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 {
if (this.gapReached) return;
this.onGoingProcessProvider.set('generatingNewAddress', true);
this.onGoingProcessProvider.set('generatingNewAddress');
this.walletProvider.getAddress(this.wallet, true).then((addr: string) => {
this.walletProvider.getMainAddresses(this.wallet, { limit: 1 }).then((_addr: any) => {
this.onGoingProcessProvider.set('generatingNewAddress', false);
this.onGoingProcessProvider.clear();
if (addr != _addr[0].address) {
this.popupProvider.ionicAlert(this.translate.instant('Error'), this.translate.instant('New address could not be generated. Please try again.'));
return;
@ -134,12 +134,12 @@ export class WalletAddressesPage {
this.viewAll = this.noBalance.length > this.UNUSED_ADDRESS_LIMIT;
}).catch((err) => {
this.logger.error(err);
this.onGoingProcessProvider.set('generatingNewAddress', false);
this.onGoingProcessProvider.clear();
this.popupProvider.ionicAlert(this.translate.instant('Error'), err);
});
}).catch((err) => {
this.logger.error(err);
this.onGoingProcessProvider.set('generatingNewAddress', false);
this.onGoingProcessProvider.clear();
if (err.toString().match('MAIN_ADDRESS_GAP_REACHED')) {
this.gapReached = true;
} else {

View File

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

View File

@ -146,9 +146,9 @@ export class TxDetailsPage {
private updateTx(opts?: any): void {
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) => {
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());
let v: string = this.txFormatProvider.formatAlternativeStr(this.wallet.coin, tx.fees);
@ -173,7 +173,7 @@ export class TxDetailsPage {
return;
});
}).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.navCtrl.pop();
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 {
this.loading = true;
this.walletProvider.publishAndSign(this.wallet, this.tx).then((txp: any) => {
this.onGoingProcessProvider.clear();
this.openFinishModal();
}).catch((err: any) => {
this.onGoingProcessProvider.clear();
this.setError(err, ('Could not send payment'));
});
}
@ -214,9 +216,12 @@ export class TxpDetailsPage {
this.popupProvider.ionicConfirm(title, msg, null, null).then((res: boolean) => {
if (!res) return
this.loading = true;
this.onGoingProcessProvider.set('rejectTx');
this.walletProvider.reject(this.wallet, this.tx).then((txpr) => {
this.onGoingProcessProvider.clear();
this.close();
}).catch((err: any) => {
this.onGoingProcessProvider.clear();
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?');
this.popupProvider.ionicConfirm(title, msg, null, null).then((res: boolean) => {
if (!res) return;
this.onGoingProcessProvider.set('removeTx', true);
this.onGoingProcessProvider.set('removeTx');
this.walletProvider.removeTx(this.wallet, this.tx).then(() => {
this.onGoingProcessProvider.set('removeTx', false);
this.onGoingProcessProvider.clear();
this.close();
}).catch((err: any) => {
this.onGoingProcessProvider.set('removeTx', false);
this.onGoingProcessProvider.clear();
if (err && !(err.message && err.message.match(/Unexpected/))) {
this.setError(err, this.translate.instant('Could not delete payment proposal'));
}
@ -242,12 +247,12 @@ export class TxpDetailsPage {
public broadcast(txp: any): void {
this.loading = true;
this.onGoingProcessProvider.set('broadcastingTx', true);
this.onGoingProcessProvider.set('broadcastingTx');
this.walletProvider.broadcastTx(this.wallet, this.tx).then((txpb: any) => {
this.onGoingProcessProvider.set('broadcastingTx', false);
this.onGoingProcessProvider.clear();
this.openFinishModal();
}).catch((err: any) => {
this.onGoingProcessProvider.set('broadcastingTx', false);
this.onGoingProcessProvider.clear();
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 { TimeProvider } from '../../providers/time/time';
import { WalletProvider } from '../../providers/wallet/wallet';
import { OnGoingProcessProvider } from '../../providers/on-going-process/on-going-process';
// pages
import { BackupWarningPage } from '../../pages/backup/backup-warning/backup-warning';
@ -52,7 +53,8 @@ export class WalletDetailsPage {
private events: Events,
private logger: Logger,
private timeProvider: TimeProvider,
private translate: TranslateService
private translate: TranslateService,
private onGoingProcessProvider: OnGoingProcessProvider
) {
let clearCache = this.navParams.data.clearCache;
this.wallet = this.profileProvider.getWallet(this.navParams.data.walletId);
@ -196,12 +198,17 @@ export class WalletDetailsPage {
};
public recreate() {
this.onGoingProcessProvider.set('recreating');
this.walletProvider.recreate(this.wallet).then(() => {
this.onGoingProcessProvider.clear();
setTimeout(() => {
this.walletProvider.startScan(this.wallet).then(() => {
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...'),
'duplicatingWallet': this.translate.instant('Duplicating wallet...'),
};
this.ongoingProcess = {};
this.ongoingProcess = [];
}
public clear() {
this.ongoingProcess = {};
this.ongoingProcess = [];
this.loading.dismiss();
this.loading = null;
this.logger.debug('ongoingProcess clear');
@ -76,29 +76,21 @@ export class OnGoingProcessProvider {
public resume(): void {
this.ongoingProcess = this.pausedOngoingProcess;
_.forEach(this.pausedOngoingProcess, (v, k) => {
this.set(k, v);
_.forEach(this.pausedOngoingProcess, (v) => {
this.set(v);
return;
});
this.pausedOngoingProcess = {};
this.pausedOngoingProcess = [];
}
public set(processName: string, isOn: boolean): void {
this.logger.debug('ongoingProcess', processName, isOn);
this.ongoingProcess[processName] = isOn;
public set(processName: string): void {
this.logger.debug('ongoingProcess active: ', processName);
this.ongoingProcess.push(processName);
let showName = this.processNames[processName] || processName;
if (!isOn) {
delete (this.ongoingProcess[processName]);
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();
if (!this.loading) {
this.loading = this.loadingCtrl.create();
}
this.loading.setContent(showName);
this.loading.present();
}
}

View File

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

View File

@ -49,7 +49,7 @@ export class WalletProvider {
private rateProvider: RateProvider,
private filter: FilterProvider,
private popupProvider: PopupProvider,
private ongoingProcessProvider: OnGoingProcessProvider,
private onGoingProcessProvider: OnGoingProcessProvider,
private touchidProvider: TouchIdProvider,
private events: Events,
private feeProvider: FeeProvider,
@ -979,10 +979,8 @@ export class WalletProvider {
public recreate(wallet: any): Promise<any> {
return new Promise((resolve, reject) => {
this.logger.debug('Recreating wallet:', wallet.id);
this.ongoingProcessProvider.set('recreating', true);
wallet.recreateWallet((err: any) => {
wallet.notAuthorized = false;
this.ongoingProcessProvider.set('recreating', false);
if (err) return reject(err);
return resolve();
});
@ -1141,14 +1139,11 @@ export class WalletProvider {
public reject(wallet: any, txp: any): Promise<any> {
return new Promise((resolve, reject) => {
this.ongoingProcessProvider.set('rejectTx', true);
this.rejectTx(wallet, txp).then((txpr: any) => {
this.invalidateCache(wallet);
this.ongoingProcessProvider.set('rejectTx', false);
this.events.publish('Local/TxAction', wallet.id);
return resolve(txpr);
}).catch((err) => {
this.ongoingProcessProvider.set('rejectTx', false);
return reject(err);
});
});
@ -1156,7 +1151,6 @@ export class WalletProvider {
public onlyPublish(wallet: any, txp: any): Promise<any> {
return new Promise((resolve, reject) => {
this.ongoingProcessProvider.set('sendingTx', true);
this.publishTx(wallet, txp).then((publishedTxp) => {
this.invalidateCache(wallet);
this.events.publish('Local/TxAction', wallet.id);
@ -1184,26 +1178,22 @@ export class WalletProvider {
private signAndBroadcast(wallet: any, publishedTxp: any, password: any): Promise<any> {
return new Promise((resolve, reject) => {
this.ongoingProcessProvider.set('signingTx', true);
this.onGoingProcessProvider.set('signingTx');
this.signTx(wallet, publishedTxp, password).then((signedTxp: any) => {
this.invalidateCache(wallet);
if (signedTxp.status == 'accepted') {
this.ongoingProcessProvider.set('broadcastingTx', true);
this.onGoingProcessProvider.set('broadcastingTx');
this.broadcastTx(wallet, signedTxp).then((broadcastedTxp: any) => {
this.ongoingProcessProvider.clear();
this.events.publish('Local/TxAction', wallet.id);
return resolve(broadcastedTxp);
}).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err));
});
} else {
this.ongoingProcessProvider.clear();
this.events.publish('Local/TxAction', wallet.id);
return resolve(signedTxp);
};
}).catch((err) => {
this.ongoingProcessProvider.clear();
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');
this.events.publish('Local/TxAction', wallet.id);
@ -1223,12 +1213,11 @@ export class WalletProvider {
return reject(err);
});
}).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err));
});
} else {
this.prepare(wallet).then((password: string) => {
this.ongoingProcessProvider.set('sendingTx', true);
this.onGoingProcessProvider.set('sendingTx');
this.publishTx(wallet, txp).then((publishedTxp: any) => {
this.signAndBroadcast(wallet, publishedTxp, password).then((broadcastedTxp: any) => {
return resolve(broadcastedTxp);
@ -1236,11 +1225,9 @@ export class WalletProvider {
return reject(err);
});
}).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err));
});
}).catch((err) => {
this.ongoingProcessProvider.clear();
return reject(this.bwcErrorProvider.msg(err));
});
};