From c187c0fb03255a7aa3761237fd7d6703257735a5 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 12 Dec 2014 15:07:48 -0300 Subject: [PATCH] Fix auto-logout after scan a QR --- js/controllers/join.js | 7 +++++++ js/controllers/send.js | 7 +++++++ js/init.js | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/js/controllers/join.js b/js/controllers/join.js index 7fac1b45a..3fb59605b 100644 --- a/js/controllers/join.js +++ b/js/controllers/join.js @@ -99,14 +99,21 @@ angular.module('copayApp.controllers').controller('JoinController', }; $scope.scannerIntent = function() { + window.usingCamera = true; cordova.plugins.barcodeScanner.scan( function onSuccess(result) { + $timeout(function(){ + window.usingCamera = false; + }, 100); if (result.cancelled) return; $scope.connectionId = result.text; $rootScope.$digest(); }, function onError(error) { + $timeout(function(){ + window.usingCamera = false; + }, 100); alert('Scanning error'); }); } diff --git a/js/controllers/send.js b/js/controllers/send.js index d9cfb9b7f..99576f8ae 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -285,8 +285,12 @@ angular.module('copayApp.controllers').controller('SendController', }; $scope.scannerIntent = function() { + window.usingCamera = true; cordova.plugins.barcodeScanner.scan( function onSuccess(result) { + $timeout(function(){ + window.usingCamera = false; + }, 100); if (result.cancelled) return; $timeout(function() { @@ -298,6 +302,9 @@ angular.module('copayApp.controllers').controller('SendController', }, 1000); }, function onError(error) { + $timeout(function(){ + window.usingCamera = false; + }, 100); alert('Scanning error'); }); } diff --git a/js/init.js b/js/init.js index 61497168a..991586ad1 100644 --- a/js/init.js +++ b/js/init.js @@ -10,7 +10,9 @@ angular.element(document).ready(function() { document.addEventListener('deviceready', function() { document.addEventListener('pause', function() { - window.location = '#!'; + if (!window.usingCamera) { + window.location = '#!'; + } }); setTimeout(function() {