Merge pull request #3193 from matiu/bug/paypro3

Bug/paypro3
This commit is contained in:
Gustavo Maximiliano Cortez 2015-09-18 11:19:33 -03:00
commit d889d4b1e5
4 changed files with 40 additions and 17 deletions

View File

@ -75,7 +75,7 @@
<div class="row" ng-show="show">
<div class="columns">
<div class="p10 enable_text_select" style="background:#eee">
<span ng-repeat="word in wordsC.mnemonicWords"><span style="white-space:nowrap">{{word}}</span><span ng-show="word.match(/[\u3041-\u308f]/)!=null">&#x3000;</span> </span>
<span ng-repeat="word in wordsC.mnemonicWords"><span style="white-space:nowrap">{{word}}</span><span ng-show="wordsC.useIdeograms">&#x3000;</span> </span>
</div>
</div>
</div>

View File

@ -7,12 +7,12 @@ angular.module('copayApp.controllers').controller('wordsController',
var successMsg = gettext('Backup words deleted');
this.done = function() {
$rootScope.$emit('Local/BackupDone');
$rootScope.$emit('Local/BackupDone');
};
this.delete = function() {
var fc = profileService.focusedClient;
confirmDialog.show(msg,function(ok){
confirmDialog.show(msg, function(ok) {
if (ok) {
fc.clearMnemonic();
profileService.updateCredentialsFC(function() {
@ -26,8 +26,10 @@ angular.module('copayApp.controllers').controller('wordsController',
var fc = profileService.focusedClient;
var words = fc.getMnemonic();
if (words)
if (words) {
this.mnemonicWords = words.split(/[\u3000\s]+/);
this.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
this.useIdeograms = words.indexOf("\u3000") >= 0;
}
this.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
});

View File

@ -953,11 +953,13 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
};
this.setFromPayPro = function(uri) {
this.setFromPayPro = function(uri, cb) {
if (!cb) cb = function() {};
var fc = profileService.focusedClient;
if (isChromeApp) {
this.error = gettext('Payment Protocol not supported on Chrome App');
return;
return cb(true);
}
var satToUnit = 1 / this.unitToSatoshi;
@ -973,23 +975,25 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess();
if (err) {
$log.warn(err);
$log.warn('Could not fetch payment request:', err);
self.resetForm();
var msg = err.toString();
if (msg.match('HTTP')) {
msg = gettext('Could not fetch payment information');
}
self.error = msg;
} else {
self._paypro = paypro;
self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals),
paypro.memo);
return cb(true);
}
self._paypro = paypro;
self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals), paypro.memo);
return cb();
});
}, 1);
};
this.setFromUri = function(uri) {
var self = this;
function sanitizeUri(uri) {
// Fixes when a region uses comma to separate decimals
var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i;
@ -1010,16 +1014,26 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return uri;
}
var parsed = new bitcore.URI(uri);
var addr = parsed.address.toString();
var addr = parsed.address ? parsed.address.toString() : '';
var message = parsed.message;
if (parsed.r)
return this.setFromPayPro(parsed.r);
var amount = parsed.amount ?
(parsed.amount.toFixed(0) * satToUnit).toFixed(this.unitDecimals) : 0;
this.setForm(addr, amount, message);
return addr;
if (parsed.r) {
this.setFromPayPro(parsed.r, function(err) {
if (err && addr && amount) {
self.setForm(addr, amount, message);
return addr;
}
});
} else {
this.setForm(addr, amount, message);
return addr;
}
};
this.onAddressChange = function(value) {

View File

@ -27,6 +27,7 @@ angular.module('copayApp.services')
}, {
name: '日本語',
isoCode: 'ja',
useIdeograms: true,
}, {
name: 'Pусский',
isoCode: 'ru',
@ -64,6 +65,12 @@ angular.module('copayApp.services')
return root.getName(root.currentLanguage);
};
root.getCurrentLanguageInfo = function() {
return lodash.find(root.availableLanguages, {
'isoCode': root.currentLanguage
});
};
root.getLanguages = function() {
return root.availableLanguages;
};