Fix back button for Android. Adds timeout and stop if error

This commit is contained in:
Gustavo Maximiliano Cortez 2017-05-01 10:02:30 -03:00
parent ffb19e00b9
commit b44b7eacad
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
1 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $log, $timeout, $http, $httpParamSerializer, profileService, configService, walletService, appConfigService) {
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $log, $timeout, $http, $httpParamSerializer, $ionicConfig, profileService, configService, walletService, appConfigService) {
var wallet, walletId;
$scope.data = {};
@ -18,6 +18,14 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
};
};
$scope.$on("$ionicView.beforeLeave", function() {
$ionicConfig.views.swipeBackEnabled(true);
});
$scope.$on("$ionicView.enter", function() {
$ionicConfig.views.swipeBackEnabled(false);
});
$scope.$on("$ionicView.beforeEnter", function(event, data) {
walletId = data.stateParams.walletId;
wallet = profileService.getWallet(walletId);
@ -47,11 +55,13 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
walletService.updateRemotePreferences(wallet, {
email: $scope.data.email,
}, function(err) {
if (err) $log.warn(err);
if (err) return;
configService.set(opts, function(err) {
if (err) $log.warn(err);
if ($scope.data.accept) collectEmail();
$scope.goNextView();
$timeout(function() {
$scope.goNextView();
}, 200);
});
});
};