Skip to content

Commit

Permalink
Fix back button for Android. Adds timeout and stop if error
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgustavo committed May 1, 2017
1 parent ffb19e0 commit b44b7ea
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/js/controllers/onboarding/collectEmail.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand All @@ -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);
Expand Down Expand Up @@ -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);
});
});
};
Expand Down

0 comments on commit b44b7ea

Please sign in to comment.