Merge pull request #2978 from matiu/bug/refresh-send

Bug/refresh send
This commit is contained in:
Gustavo Maximiliano Cortez 2015-07-13 14:11:38 -03:00
commit 454724eb5f
4 changed files with 39 additions and 43 deletions

View file

@ -253,7 +253,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$log.debug('Retrying update... Try:' + tries) $log.debug('Retrying update... Try:' + tries)
return self.updateAll({ return self.updateAll({
walletStatus: null, walletStatus: null,
untilItChanges: true untilItChanges: true,
triggerTxUpdate: opts.triggerTxUpdate,
}, initStatusHash, ++tries); }, initStatusHash, ++tries);
}, 1400 * tries); }, 1400 * tries);
} }
@ -432,14 +433,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
self.setTxHistory = function(txs) { self.setTxHistory = function(txs) {
var now = new Date(); var now = Math.floor(Date.now() / 1000);
var c = 0; var c = 0;
self.txHistoryPaging = txs[self.limitHistory] ? true : false; self.txHistoryPaging = txs[self.limitHistory] ? true : false;
lodash.each(txs, function(tx) { lodash.each(txs, function(tx) {
tx.ts = tx.minedTs || tx.sentTs;
// no future transaction... // no future transactions...
if (tx.ts > now) if (tx.time > now)
ts.ts = now; tx.time = now;
tx.rateTs = Math.floor((tx.ts || now) / 1000); tx.rateTs = Math.floor((tx.ts || now) / 1000);
tx.amountStr = profileService.formatAmount(tx.amount); //$filter('noFractionNumber')( tx.amountStr = profileService.formatAmount(tx.amount); //$filter('noFractionNumber')(
if (c < self.limitHistory) { if (c < self.limitHistory) {

View file

@ -32,7 +32,6 @@ angular.module('copayApp.controllers').controller('preferencesFeeController',
configService.set(opts, function(err) { configService.set(opts, function(err) {
if (err) console.log(err); if (err) console.log(err);
$scope.$emit('Local/UnitSettingUpdated');
}); });
}; };

View file

@ -745,6 +745,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
profileService.lockFC(); profileService.lockFC();
self.setOngoingProcess(); self.setOngoingProcess();
if (err) { if (err) {
$log.debug('Sign error:', err);
err.message = gettext('The payment was created but could not be signed. Please try again from home screen.') + (err.message ? ' ' + err.message : ''); err.message = gettext('The payment was created but could not be signed. Please try again from home screen.') + (err.message ? ' ' + err.message : '');
return cb(err); return cb(err);
} }
@ -958,22 +959,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return this.alternativeIsoCode; return this.alternativeIsoCode;
}; };
this._addRates = function(txs, cb) {
if (!txs || txs.length == 0) return cb();
var index = lodash.groupBy(txs, 'rateTs');
rateService.getHistoricRates(config.alternativeIsoCode, lodash.keys(index), function(err, res) {
if (err || !res) return cb(err);
lodash.each(res, function(r) {
lodash.each(index[r.ts], function(tx) {
var alternativeAmount = (r.rate != null ? tx.amount * rateService.SAT_TO_BTC * r.rate : null);
tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null;
});
});
return cb();
});
};
this.openTxModal = function(btx) { this.openTxModal = function(btx) {
var self = this; var self = this;
var fc = profileService.focusedClient; var fc = profileService.focusedClient;

View file

@ -28,7 +28,7 @@ angular
var orig = $delegate[level]; var orig = $delegate[level];
$delegate[level] = function() { $delegate[level] = function() {
if (level=='error') if (level == 'error')
console.log(arguments); console.log(arguments);
var args = [].slice.call(arguments); var args = [].slice.call(arguments);
@ -43,9 +43,13 @@ angular
else else
v = JSON.stringify(v); v = JSON.stringify(v);
} }
v = v.toString(); // Trim output in mobile
if (v.length > 200) if ( window.cordova ) {
v = v.substr(0, 197) + '...'; v = v.toString();
if (v.length > 1000) {
v = v.substr(0, 997) + '...';
}
}
} catch (e) { } catch (e) {
console.log('Error at log decorator:', e); console.log('Error at log decorator:', e);
v = 'undefined'; v = 'undefined';
@ -85,7 +89,9 @@ angular
$scope.create = function(noWallet) { $scope.create = function(noWallet) {
$scope.creatingProfile = true; $scope.creatingProfile = true;
profileService.create({noWallet: noWallet}, function(err) { profileService.create({
noWallet: noWallet
}, function(err) {
if (err) { if (err) {
$scope.creatingProfile = false; $scope.creatingProfile = false;
$log.warn(err); $log.warn(err);
@ -100,7 +106,8 @@ angular
} }
} }
} }
}) });
$stateProvider $stateProvider
.state('disclaimer', { .state('disclaimer', {
url: '/disclaimer', url: '/disclaimer',
@ -111,14 +118,14 @@ angular
controller: function($scope, $timeout, storageService, applicationService, go) { controller: function($scope, $timeout, storageService, applicationService, go) {
storageService.getCopayDisclaimerFlag(function(err, val) { storageService.getCopayDisclaimerFlag(function(err, val) {
$scope.agreed = val; $scope.agreed = val;
$timeout(function(){ $timeout(function() {
$scope.$digest(); $scope.$digest();
}, 1); }, 1);
}); });
$scope.agree = function() { $scope.agree = function() {
storageService.setCopayDisclaimerFlag(function(err) { storageService.setCopayDisclaimerFlag(function(err) {
$timeout(function(){ $timeout(function() {
applicationService.restart(); applicationService.restart();
}, 1000); }, 1000);
}); });
@ -256,8 +263,8 @@ angular
}, },
} }
}) })
.state('preferencesAdvanced', { .state('preferencesAdvanced', {
url: '/preferencesAdvanced', url: '/preferencesAdvanced',
templateUrl: 'views/preferencesAdvanced.html', templateUrl: 'views/preferencesAdvanced.html',
walletShouldBeComplete: true, walletShouldBeComplete: true,
@ -438,10 +445,12 @@ angular
if (nodeWebkit.isDefined()) { if (nodeWebkit.isDefined()) {
var gui = require('nw.gui'); var gui = require('nw.gui');
var win = gui.Window.get(); var win = gui.Window.get();
var nativeMenuBar = new gui.Menu({ type: "menubar" }); var nativeMenuBar = new gui.Menu({
type: "menubar"
});
try { try {
nativeMenuBar.createMacBuiltin("Copay"); nativeMenuBar.createMacBuiltin("Copay");
} catch(e) { } catch (e) {
$log.debug('This is not OSX'); $log.debug('This is not OSX');
} }
win.menu = nativeMenuBar; win.menu = nativeMenuBar;
@ -516,7 +525,8 @@ angular
*/ */
function cleanUpLater(e, e2) { function cleanUpLater(e, e2) {
var cleanedUp = false, timeoutID; var cleanedUp = false,
timeoutID;
var cleanUp = function() { var cleanUp = function() {
if (cleanedUp) return; if (cleanedUp) return;
cleanedUp = true; cleanedUp = true;
@ -526,7 +536,7 @@ angular
cachedBackPanel = null; cachedBackPanel = null;
cachedTransitionState = ''; cachedTransitionState = '';
if (timeoutID) { if (timeoutID) {
timeoutID=null; timeoutID = null;
window.clearTimeout(timeoutID); window.clearTimeout(timeoutID);
} }
}; };
@ -551,7 +561,7 @@ angular
var fromName = fromState.name; var fromName = fromState.name;
var toName = toState.name; var toName = toState.name;
if (!fromName || !toName) if (!fromName || !toName)
return true; return true;
var fromWeight = pageWeight[fromName]; var fromWeight = pageWeight[fromName];
@ -569,7 +579,7 @@ angular
entering = 'CslideInRight'; entering = 'CslideInRight';
} }
// Vertical Slide Animation? // Vertical Slide Animation?
} else if (fromName && fromWeight >= 0 && toWeight >= 0) { } else if (fromName && fromWeight >= 0 && toWeight >= 0) {
if (toWeight) { if (toWeight) {
entering = 'CslideInUp'; entering = 'CslideInUp';
@ -577,7 +587,7 @@ angular
leaving = 'CslideOutDown'; leaving = 'CslideOutDown';
} }
// no Animation ? // no Animation ?
} else { } else {
return true; return true;
} }
@ -596,8 +606,8 @@ angular
} else { } else {
var sc; var sc;
// Keep prefDiv scroll // Keep prefDiv scroll
var contentDiv = e.getElementsByClassName('content'); var contentDiv = e.getElementsByClassName('content');
if (contentDiv && contentDiv[0]) if (contentDiv && contentDiv[0])
sc = contentDiv[0].scrollTop; sc = contentDiv[0].scrollTop;
cachedBackPanel = e.cloneNode(true); cachedBackPanel = e.cloneNode(true);
@ -606,7 +616,7 @@ angular
c.appendChild(cachedBackPanel); c.appendChild(cachedBackPanel);
if (sc) if (sc)
cachedBackPanel.getElementsByClassName('content')[0].scrollTop = sc; cachedBackPanel.getElementsByClassName('content')[0].scrollTop = sc;
cachedTransitionState = desiredTransitionState; cachedTransitionState = desiredTransitionState;
//console.log('CACHing animation', cachedTransitionState); //console.log('CACHing animation', cachedTransitionState);