handle errors when creating first wallet
This commit is contained in:
parent
767b523499
commit
ea93cd6870
2 changed files with 24 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('copayApp.controllers').controller('tourController',
|
angular.module('copayApp.controllers').controller('tourController',
|
||||||
function($scope, $state, $log, $timeout, $filter, ongoingProcess, platformInfo, profileService, rateService) {
|
function($scope, $state, $log, $timeout, $filter, ongoingProcess, platformInfo, profileService, rateService, popupService, gettextCatalog) {
|
||||||
|
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
var isWP = platformInfo.isWP;
|
var isWP = platformInfo.isWP;
|
||||||
|
|
@ -37,6 +37,7 @@ angular.module('copayApp.controllers').controller('tourController',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var retryCount = 0;
|
||||||
$scope.createDefaultWallet = function() {
|
$scope.createDefaultWallet = function() {
|
||||||
ongoingProcess.set('creatingWallet', true);
|
ongoingProcess.set('creatingWallet', true);
|
||||||
profileService.createDefaultWallet(function(err, walletClient) {
|
profileService.createDefaultWallet(function(err, walletClient) {
|
||||||
|
|
@ -44,19 +45,27 @@ angular.module('copayApp.controllers').controller('tourController',
|
||||||
$log.warn(err);
|
$log.warn(err);
|
||||||
|
|
||||||
return $timeout(function() {
|
return $timeout(function() {
|
||||||
$log.warn('Retrying to create default wallet......');
|
$log.warn('Retrying to create default wallet.....:' + ++retryCount);
|
||||||
return $scope.createDefaultWallet();
|
if (retryCount > 3) {
|
||||||
}, 3000);
|
ongoingProcess.set('creatingWallet', false);
|
||||||
|
popupService.showAlert(
|
||||||
|
gettextCatalog.getString('Cannot Create Wallet'), err,
|
||||||
|
function() {
|
||||||
|
retryCount = 0;
|
||||||
|
return $scope.createDefaultWallet();
|
||||||
|
}, gettextCatalog.getString('Retry'));
|
||||||
|
} else {
|
||||||
|
return $scope.createDefaultWallet();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
};
|
};
|
||||||
ongoingProcess.set('creatingWallet', false);
|
|
||||||
var wallet = walletClient;
|
var wallet = walletClient;
|
||||||
var walletId = wallet.credentials.walletId;
|
var walletId = wallet.credentials.walletId;
|
||||||
if (!usePushNotifications) {
|
if (!usePushNotifications) {
|
||||||
$state.go('onboarding.backupRequest', {
|
$state.go('onboarding.backupRequest', {
|
||||||
walletId: walletId
|
walletId: walletId
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$state.go('onboarding.notifications', {
|
$state.go('onboarding.notifications', {
|
||||||
walletId: walletId
|
walletId: walletId
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
|
||||||
|
|
||||||
/*************** Ionic ****************/
|
/*************** Ionic ****************/
|
||||||
|
|
||||||
var _ionicAlert = function(title, message, cb) {
|
var _ionicAlert = function(title, message, cb, buttonName) {
|
||||||
if (!cb) cb = function() {};
|
if (!cb) cb = function() {};
|
||||||
$ionicPopup.alert({
|
$ionicPopup.alert({
|
||||||
title: title,
|
title: title,
|
||||||
subTitle: message,
|
subTitle: message,
|
||||||
okType: 'button-clear button-positive'
|
okType: 'button-clear button-positive',
|
||||||
|
okText: buttonName || gettextCatalog.getString('OK'),
|
||||||
}).then(cb);
|
}).then(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -43,9 +44,9 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
|
||||||
|
|
||||||
/*************** Cordova ****************/
|
/*************** Cordova ****************/
|
||||||
|
|
||||||
var _cordovaAlert = function(title, message, cb) {
|
var _cordovaAlert = function(title, message, cb, buttonName) {
|
||||||
if (!cb) cb = function() {};
|
if (!cb) cb = function() {};
|
||||||
navigator.notification.alert(message, cb, title);
|
navigator.notification.alert(message, cb, title, buttonName);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _cordovaConfirm = function(title, message, okText, cancelText, cb) {
|
var _cordovaConfirm = function(title, message, okText, cancelText, cb) {
|
||||||
|
|
@ -74,14 +75,14 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
|
||||||
* @param {Callback} Function (optional)
|
* @param {Callback} Function (optional)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.showAlert = function(title, msg, cb) {
|
this.showAlert = function(title, msg, cb, buttonName) {
|
||||||
var message = (msg && msg.message) ? msg.message : msg;
|
var message = (msg && msg.message) ? msg.message : msg;
|
||||||
$log.warn(title + ": " + message);
|
$log.warn(title + ": " + message);
|
||||||
|
|
||||||
if (isCordova)
|
if (isCordova)
|
||||||
_cordovaAlert(title, message, cb);
|
_cordovaAlert(title, message, cb, buttonName);
|
||||||
else
|
else
|
||||||
_ionicAlert(title, message, cb);
|
_ionicAlert(title, message, cb, buttonName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue