From 7028f6f1c53b0e1c4b34bcdf0b46cca9f4590e15 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 27 Apr 2015 02:07:26 -0300 Subject: [PATCH] fix timming in modal --- src/js/controllers/index.js | 2 +- src/js/controllers/walletHome.js | 20 ++++++++------------ src/js/routes.js | 8 ++++++-- src/js/services/txStatus.js | 15 +++++++-------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 71edde1f4..82c5cfb63 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -649,7 +649,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.updateAll(); $timeout(function() { self.updateTxHistory(); - }, 5000); + }, 3000); }); }); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index e01f78f91..072571759 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -486,10 +486,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi } self.signAndBroadcast(txp, function(err) { - profileService.lockFC(); - if (err) { + if (err) return self.setError(err); - } + self.resetForm(); }); }); @@ -504,9 +503,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi profileService.lockFC(); self.setOngoingProcess(); - if (err) { + if (err) return cb(err); - } if (signedTx.status == 'accepted') { self.setOngoingProcess('Broadcasting transaction'); @@ -515,16 +513,14 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi if (err) { $scope.error = 'Transaction not broadcasted. Please try again.'; $scope.$digest(); - } else { - txStatus.notify(btx); - $scope.$emit('Local/TxProposalAction'); - } - return cb(); + return; + } + $scope.$emit('Local/TxProposalAction'); + txStatus.notify(btx, cb); }); } else { - txStatus.notify(signedTx); $scope.$emit('Local/TxProposalAction'); - return cb(); + txStatus.notify(signedTx, cb); } }); }; diff --git a/src/js/routes.js b/src/js/routes.js index b03013a13..3c42ffcd5 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -28,11 +28,15 @@ angular var orig = $delegate[level]; $delegate[level] = function() { var args = [].slice.call(arguments); + if (!Array.isArray(args)) args = [args]; args = args.map(function(v) { try { if (typeof v == 'undefined') v = 'undefined'; if (typeof v == 'object') { - v = JSON.stringify(v); + if (v.message) + v = v.message; + else + v = JSON.stringify(v); } v = v.toString(); if (v.length > 200) @@ -46,7 +50,7 @@ angular try { if (window.cordova) console.log(args.join(' ')); - orig.apply(null, args) + orig.apply(null, args); historicLog.add(level, args.join(' ')); } catch (e) { console.log('Error at log decorator:', e); diff --git a/src/js/services/txStatus.js b/src/js/services/txStatus.js index 9f048dce3..3e76a8933 100644 --- a/src/js/services/txStatus.js +++ b/src/js/services/txStatus.js @@ -1,18 +1,17 @@ 'use strict'; -angular.module('copayApp.services').factory('txStatus', function($modal, lodash, profileService) { +angular.module('copayApp.services').factory('txStatus', function($modal, lodash, profileService, $timeout) { var root = {}; - root.notify = function(txp) { + root.notify = function(txp, cb) { var fc = profileService.focusedClient; var msg; var status = txp.status; - + if (status == 'broadcasted') { msg = 'Transaction broadcasted'; - } - else { + } else { var action = lodash.find(txp.actions, { copayerId: fc.credentials.copayerId }); @@ -25,16 +24,16 @@ angular.module('copayApp.services').factory('txStatus', function($modal, lodash, } } - if (msg) - root.openModal(msg); + root.openModal(msg, cb); }; - root.openModal = function(statusStr) { + root.openModal = function(statusStr, cb) { var ModalInstanceCtrl = function($scope, $modalInstance) { $scope.statusStr = statusStr; $scope.cancel = function() { $modalInstance.dismiss('cancel'); }; + if (cb) $timeout(cb, 100); }; $modal.open({ templateUrl: 'views/modals/tx-status.html',