From a95f37ce54f720e50a67cbbc8ad469c6e3f7c28e Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 2 Sep 2016 10:30:26 -0300 Subject: [PATCH 1/2] fix txStatus modal --- public/views/modals/txp-details.html | 2 +- src/js/controllers/confirm.js | 2 +- src/js/controllers/modals/txStatus.js | 1 - src/js/controllers/modals/txpDetails.js | 27 ++----------- src/js/controllers/paperWallet.js | 4 +- src/js/services/txStatus.js | 41 -------------------- src/js/services/walletService.js | 50 +++++++++++++++++++++---- 7 files changed, 50 insertions(+), 77 deletions(-) delete mode 100644 src/js/services/txStatus.js diff --git a/public/views/modals/txp-details.html b/public/views/modals/txp-details.html index fdc3ba9f2..af12277a0 100644 --- a/public/views/modals/txp-details.html +++ b/public/views/modals/txp-details.html @@ -1,7 +1,7 @@ diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index f6f6523b3..9fd24fa7a 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) { +angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) { $ionicNavBarDelegate.title(gettextCatalog.getString('Confirm')); var cachedTxp = {}; var isChromeApp = platformInfo.isChromeApp; diff --git a/src/js/controllers/modals/txStatus.js b/src/js/controllers/modals/txStatus.js index e9e3aa537..05037eedd 100644 --- a/src/js/controllers/modals/txStatus.js +++ b/src/js/controllers/modals/txStatus.js @@ -7,5 +7,4 @@ angular.module('copayApp.controllers').controller('txStatusController', function $scope.cancel = function() { $scope.txStatusModal.hide(); }; - }); diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index e76acb50b..dadc6309e 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService) { +angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService) { var self = $scope.self; var tx = $scope.tx; var copayers = $scope.copayers; @@ -32,6 +32,9 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi $scope.sign = function() { $scope.loading = true; walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) { + +console.log('[txpDetails.js.35] AFTER publush'); //TODO + $scope.$emit('UpdateTx'); if (err) return setSendError(err); $scope.close(txp); @@ -174,28 +177,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi $scope.close = function(txp) { $scope.loading = null; - if (txp) { - var type = txStatus.notify(txp); - $scope.openStatusModal(type, txp, function() {}); - } - $scope.cancel(); - }; - - $scope.openStatusModal = function(type, txp, cb) { - $scope.type = type; - $scope.tx = txFormatService.processTx(txp); - $scope.cb = cb; - - $ionicModal.fromTemplateUrl('views/modals/tx-status.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function(modal) { - $scope.txStatusModal = modal; - $scope.txStatusModal.show(); - }); - }; - - $scope.cancel = function() { $scope.txpDetailsModal.hide(); }; }); diff --git a/src/js/controllers/paperWallet.js b/src/js/controllers/paperWallet.js index 551565d8c..db0d21bca 100644 --- a/src/js/controllers/paperWallet.js +++ b/src/js/controllers/paperWallet.js @@ -1,5 +1,5 @@ angular.module('copayApp.controllers').controller('paperWalletController', - function($scope, $timeout, $log, $ionicModal, configService, profileService, $state, addressService, txStatus, bitcore, ongoingProcess, txFormatService, $stateParams) { + function($scope, $timeout, $log, $ionicModal, configService, profileService, $state, addressService, bitcore, ongoingProcess, txFormatService, $stateParams, walletService) { var wallet = profileService.getWallet($stateParams.walletId); var rawTx; @@ -100,7 +100,7 @@ angular.module('copayApp.controllers').controller('paperWalletController', $scope.error = err.message || err.toString(); $log.error(err); } else { - var type = txStatus.notify(txp); + var type = walletService.getViewStatus(wallet, txp); $scope.openStatusModal(type, txp, function() { $state.go('tabs.home'); }); diff --git a/src/js/services/txStatus.js b/src/js/services/txStatus.js deleted file mode 100644 index ab94dbe46..000000000 --- a/src/js/services/txStatus.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -angular.module('copayApp.services').factory('txStatus', function($stateParams, lodash, profileService, $timeout, platformInfo) { - var root = {}; - var isCordova = platformInfo.isCordova; - - root.notify = function(txp) { - var wallet = profileService.getWallet(txp.walletId); - var status = txp.status; - var type; - var INMEDIATE_SECS = 10; - - if (status == 'broadcasted') { - type = 'broadcasted'; - } else { - - var n = txp.actions.length; - var action = lodash.find(txp.actions, { - copayerId: wallet.credentials.copayerId - }); - - if (!action) { - type = 'created'; - } else if (action.type == 'accept') { - // created and accepted at the same time? - if (n == 1 && action.createdOn - txp.createdOn < INMEDIATE_SECS) { - type = 'created'; - } else { - type = 'accepted'; - } - } else if (action.type == 'reject') { - type = 'rejected'; - } else { - throw new Error('Unknown type:' + type); - } - } - return type; - }; - - return root; -}); diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 4f3519514..6293c31c3 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) { +angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) { // `wallet` is a decorated version of client. var root = {}; @@ -674,11 +674,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim handleError(err); return; } + root.startScan(wallet); - profileService.bindWalletClient(wallet, { - force: true - }); - wallet.startScan(wallet); + // TODO TODO TODO TODO: + // Do it on the controller + // profileService.bindWalletClient(wallet, { + // force: true + // }); }); }; @@ -878,7 +880,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim ongoingProcess.set('sendingTx', false); if (err) return cb(err); - var type = txStatus.notify(createdTxp); + var type = root.getViewStatus(wallet, createdTxp); root.openStatusModal(type, createdTxp, function() { $rootScope.$emit('Local/TxAction', wallet.id); return; @@ -941,7 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim ongoingProcess.set('broadcastingTx', false); if (err) return cb('sign error' + err); - var type = txStatus.notify(broadcastedTxp); + var type = root.getViewStatus(wallet, broadcastedTxp); root.openStatusModal(type, broadcastedTxp, function() { $rootScope.$emit('Local/TxAction', wallet.id); }); @@ -949,7 +951,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim return cb(null, broadcastedTxp) }); } else { - var type = txStatus.notify(signedTxp); + var type = root.getViewStatus(wallet, signedTxp); root.openStatusModal(type, signedTxp, function() { root.invalidateCache(wallet); $rootScope.$emit('Local/TxAction', wallet.id); @@ -1026,6 +1028,38 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; + root.getViewStatus = function(wallet, txp) { + var status = txp.status; + var type; + var INMEDIATE_SECS = 10; + + if (status == 'broadcasted') { + type = 'broadcasted'; + } else { + + var n = txp.actions.length; + var action = lodash.find(txp.actions, { + copayerId: wallet.credentials.copayerId + }); + + if (!action) { + type = 'created'; + } else if (action.type == 'accept') { + // created and accepted at the same time? + if (n == 1 && action.createdOn - txp.createdOn < INMEDIATE_SECS) { + type = 'created'; + } else { + type = 'accepted'; + } + } else if (action.type == 'reject') { + type = 'rejected'; + } else { + throw new Error('Unknown type:' + type); + } + } + return type; + }; + return root; }); From 4662b2fc921f9edb3093549935e93e3d52d84930 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 2 Sep 2016 10:32:22 -0300 Subject: [PATCH 2/2] add translate --- public/views/includes/walletActivity.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/views/includes/walletActivity.html b/public/views/includes/walletActivity.html index c57caae8b..ed0f57e07 100644 --- a/public/views/includes/walletActivity.html +++ b/public/views/includes/walletActivity.html @@ -1,9 +1,9 @@ -
+
Copayer joined
-
+
Wallet created