fix txStatus modal
This commit is contained in:
parent
e286e7ea56
commit
a95f37ce54
7 changed files with 50 additions and 77 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<ion-modal-view ng-controller="txpDetailsController">
|
<ion-modal-view ng-controller="txpDetailsController">
|
||||||
<ion-header-bar align-title="center" class="tab-bar">
|
<ion-header-bar align-title="center" class="tab-bar">
|
||||||
<div class="left-small">
|
<div class="left-small">
|
||||||
<a ng-click="cancel()" class="p10">
|
<a ng-click="close()" class="p10">
|
||||||
<span class="text-close" translate>Close</span>
|
<span class="text-close" translate>Close</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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'));
|
$ionicNavBarDelegate.title(gettextCatalog.getString('Confirm'));
|
||||||
var cachedTxp = {};
|
var cachedTxp = {};
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
var isChromeApp = platformInfo.isChromeApp;
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,4 @@ angular.module('copayApp.controllers').controller('txStatusController', function
|
||||||
$scope.cancel = function() {
|
$scope.cancel = function() {
|
||||||
$scope.txStatusModal.hide();
|
$scope.txStatusModal.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 self = $scope.self;
|
||||||
var tx = $scope.tx;
|
var tx = $scope.tx;
|
||||||
var copayers = $scope.copayers;
|
var copayers = $scope.copayers;
|
||||||
|
|
@ -32,6 +32,9 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
$scope.sign = function() {
|
$scope.sign = function() {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
|
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
|
||||||
|
|
||||||
|
console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
||||||
|
|
||||||
$scope.$emit('UpdateTx');
|
$scope.$emit('UpdateTx');
|
||||||
if (err) return setSendError(err);
|
if (err) return setSendError(err);
|
||||||
$scope.close(txp);
|
$scope.close(txp);
|
||||||
|
|
@ -174,28 +177,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
|
|
||||||
$scope.close = function(txp) {
|
$scope.close = function(txp) {
|
||||||
$scope.loading = null;
|
$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();
|
$scope.txpDetailsModal.hide();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
angular.module('copayApp.controllers').controller('paperWalletController',
|
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 wallet = profileService.getWallet($stateParams.walletId);
|
||||||
var rawTx;
|
var rawTx;
|
||||||
|
|
@ -100,7 +100,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
|
||||||
$scope.error = err.message || err.toString();
|
$scope.error = err.message || err.toString();
|
||||||
$log.error(err);
|
$log.error(err);
|
||||||
} else {
|
} else {
|
||||||
var type = txStatus.notify(txp);
|
var type = walletService.getViewStatus(wallet, txp);
|
||||||
$scope.openStatusModal(type, txp, function() {
|
$scope.openStatusModal(type, txp, function() {
|
||||||
$state.go('tabs.home');
|
$state.go('tabs.home');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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;
|
|
||||||
});
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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.
|
// `wallet` is a decorated version of client.
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
@ -674,11 +674,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
handleError(err);
|
handleError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
root.startScan(wallet);
|
||||||
|
|
||||||
profileService.bindWalletClient(wallet, {
|
// TODO TODO TODO TODO:
|
||||||
force: true
|
// Do it on the controller
|
||||||
});
|
// profileService.bindWalletClient(wallet, {
|
||||||
wallet.startScan(wallet);
|
// force: true
|
||||||
|
// });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -878,7 +880,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
ongoingProcess.set('sendingTx', false);
|
ongoingProcess.set('sendingTx', false);
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
var type = txStatus.notify(createdTxp);
|
var type = root.getViewStatus(wallet, createdTxp);
|
||||||
root.openStatusModal(type, createdTxp, function() {
|
root.openStatusModal(type, createdTxp, function() {
|
||||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||||
return;
|
return;
|
||||||
|
|
@ -941,7 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
ongoingProcess.set('broadcastingTx', false);
|
ongoingProcess.set('broadcastingTx', false);
|
||||||
if (err) return cb('sign error' + err);
|
if (err) return cb('sign error' + err);
|
||||||
|
|
||||||
var type = txStatus.notify(broadcastedTxp);
|
var type = root.getViewStatus(wallet, broadcastedTxp);
|
||||||
root.openStatusModal(type, broadcastedTxp, function() {
|
root.openStatusModal(type, broadcastedTxp, function() {
|
||||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||||
});
|
});
|
||||||
|
|
@ -949,7 +951,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
return cb(null, broadcastedTxp)
|
return cb(null, broadcastedTxp)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var type = txStatus.notify(signedTxp);
|
var type = root.getViewStatus(wallet, signedTxp);
|
||||||
root.openStatusModal(type, signedTxp, function() {
|
root.openStatusModal(type, signedTxp, function() {
|
||||||
root.invalidateCache(wallet);
|
root.invalidateCache(wallet);
|
||||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
$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;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue