3rd step enhancement send flow
This commit is contained in:
parent
480cfe43ca
commit
2c0432e292
7 changed files with 77 additions and 110 deletions
|
|
@ -21,10 +21,6 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
|||
});
|
||||
|
||||
$scope.sendTo = function() {
|
||||
$ionicHistory.removeBackView();
|
||||
sendFlowService.clear();
|
||||
$state.go('tabs.send');
|
||||
$timeout(function() {
|
||||
var to = '';
|
||||
if ($scope.addressbookEntry.coin == 'bch') {
|
||||
var a = 'bitcoincash:' + $scope.addressbookEntry.address;
|
||||
|
|
@ -40,9 +36,7 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
|||
coin: $scope.addressbookEntry.coin
|
||||
};
|
||||
|
||||
sendFlowService.pushState(stateParams);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}, 100);
|
||||
sendFlowService.start(stateParams);
|
||||
};
|
||||
|
||||
$scope.remove = function(addressbookEntry) {
|
||||
|
|
|
|||
|
|
@ -62,18 +62,7 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi
|
|||
id: 'shapeshift'
|
||||
}
|
||||
};
|
||||
|
||||
// Starting new send flow, so ensure everything is reset
|
||||
sendFlowService.clear();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.send').then(function() {
|
||||
$timeout(function () {
|
||||
sendFlowService.pushState(stateParams);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}, 60);
|
||||
});
|
||||
});
|
||||
sendFlowService.start(stateParams);
|
||||
}
|
||||
|
||||
function showMyAddress() {
|
||||
|
|
|
|||
|
|
@ -122,8 +122,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
};
|
||||
|
||||
$scope.startFreshSend = function() {
|
||||
sendFlowService.clear();
|
||||
$state.go('tabs.send');
|
||||
sendFlowService.start();
|
||||
}
|
||||
|
||||
$scope.openExternalLink = function() {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro
|
|||
};
|
||||
|
||||
$scope.chooseScanner = function() {
|
||||
sendFlowService.clear();
|
||||
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||
|
||||
if (!isWindowsPhoneApp) {
|
||||
|
|
|
|||
|
|
@ -378,8 +378,6 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
sendFlowService.clear();
|
||||
|
||||
configService.whenAvailable(function (config) {
|
||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||
|
||||
|
|
@ -477,15 +475,15 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
}
|
||||
|
||||
$scope.goToSend = function() {
|
||||
sendFlowService.startSend({
|
||||
sendFlowService.start({
|
||||
fromWalletId: $scope.wallet.id
|
||||
});
|
||||
|
||||
// Go home first so that the Home tab works properly
|
||||
$state.go('tabs.home').then(function () {
|
||||
/*$state.go('tabs.home').then(function () {
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.send');
|
||||
});
|
||||
});*/
|
||||
|
||||
};
|
||||
$scope.goToReceive = function() {
|
||||
|
|
|
|||
|
|
@ -85,13 +85,7 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
|||
}
|
||||
|
||||
function goSend(addr, amount, message, coin, serviceId, serviceData) {
|
||||
$state.go('tabs.send', {}, {
|
||||
'reload': true,
|
||||
'notify': $state.current.name == 'tabs.send' ? false : true
|
||||
});
|
||||
// Timeout is required to enable the "Back" button
|
||||
$timeout(function() {
|
||||
var params = sendFlowService.getStateClone();
|
||||
var params = sendFlowService.state.getClone();
|
||||
|
||||
if (amount) {
|
||||
params.amount = amount;
|
||||
|
|
@ -114,32 +108,14 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
|||
params.thirdParty = [];
|
||||
params.thirdParty.id = serviceId;
|
||||
params.thirdParty.data = serviceData;
|
||||
sendFlowService.pushState(params);
|
||||
$state.transitionTo('tabs.send.amount');
|
||||
} else {
|
||||
sendFlowService.pushState(params);
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
}
|
||||
}, 100);
|
||||
|
||||
sendFlowService.start(params);
|
||||
}
|
||||
// data extensions for Payment Protocol with non-backwards-compatible request
|
||||
if (allParsed.isValid && allParsed.coin && allParsed.url && !allParsed.testnet) {
|
||||
var coin = allParsed.coin;
|
||||
data = allParsed.url;
|
||||
if (allParsed.coin == 'bch') {
|
||||
payproService.getPayProDetailsViaHttp(data, function onGetPayProDetailsViaHttp(err, details) {
|
||||
if (err) {
|
||||
var message = err.toString();
|
||||
if (typeof err.data === 'string') {
|
||||
// i.e. 'This invoice is no longer accepting payments'
|
||||
message = gettextCatalog.getString(err.data);
|
||||
}
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), message)
|
||||
} else {
|
||||
handlePayPro(details, allParsed.coin);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
payproService.getPayProDetails(data, allParsed.coin, function onGetPayProDetails(err, details) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
|
|
@ -147,7 +123,6 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
|||
handlePayPro(details, allParsed.coin);
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ angular
|
|||
|
||||
function sendFlowRouterService(
|
||||
sendFlowStateService
|
||||
, $state, $ionicHistory
|
||||
, $state, $ionicHistory, $timeout
|
||||
) {
|
||||
|
||||
var service = {
|
||||
|
|
@ -30,8 +30,11 @@ angular
|
|||
if ($state.current.name != 'tabs.send') {
|
||||
$state.go('tabs.home').then(function () {
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.send');
|
||||
$state.go('tabs.send').then(function () {
|
||||
$timeout(function () {
|
||||
goNext();
|
||||
}, 60);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
goNext();
|
||||
|
|
@ -39,22 +42,32 @@ angular
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Strategy
|
||||
* https://bitcoindotcom.atlassian.net/wiki/x/BQDWKQ
|
||||
*/
|
||||
function goNext() {
|
||||
var state = sendFlowStateService.state;
|
||||
|
||||
/**
|
||||
* Strategy
|
||||
*/
|
||||
if (!state.fromWalletId && (state.isWalletTransfer || (state.toWalletId || state.toAddress))) {
|
||||
$state.transitionTo('tabs.send.origin');
|
||||
} else if (state.fromWalletId && !state.toWalletId && !state.toAddress) {
|
||||
$state.transitionTo('tabs.send.destination');
|
||||
} else if (state.fromWalletId && (state.toWalletId || state.toAddress) && !state.amount) {
|
||||
$state.transitionTo('tabs.send.amount');
|
||||
} else if (state.fromWalletId && (state.toWalletId || state.toAddress) && state.amount) {
|
||||
$state.transitionTo('tabs.send.review');
|
||||
var needsDestination = !state.toWalletId && !state.toAddress;
|
||||
var needsOrigin = !state.fromWalletId;
|
||||
var needsAmount = !state.amount && !state.sendMax;
|
||||
|
||||
if (needsDestination) {
|
||||
if (!state.isWalletTransfer && !state.thirdParty) {
|
||||
$state.go('tabs.send');
|
||||
return;
|
||||
} else if (!needsOrigin) {
|
||||
$state.go('tabs.send.destination');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (needsOrigin) {
|
||||
$state.go('tabs.send.origin');
|
||||
} else if (needsAmount) {
|
||||
$state.go('tabs.send.amount');
|
||||
} else {
|
||||
$state.go('tabs.send.review');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue