From 74c30a70b91d97c2d7397ebcba982eb25ff47892 Mon Sep 17 00:00:00 2001 From: Gunther Brunner Date: Mon, 18 Aug 2014 18:56:58 +0900 Subject: [PATCH] Added safety 2nd timeout to startRemoteConnect. --- .../remote-debug/remote-debug-controller.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/res/app/control-panes/dashboard/remote-debug/remote-debug-controller.js b/res/app/control-panes/dashboard/remote-debug/remote-debug-controller.js index 2c1aa81c..dc3798e8 100644 --- a/res/app/control-panes/dashboard/remote-debug/remote-debug-controller.js +++ b/res/app/control-panes/dashboard/remote-debug/remote-debug-controller.js @@ -1,17 +1,24 @@ module.exports = function RemoteDebugCtrl($scope, $timeout) { function startRemoteConnect() { - $scope.control.startRemoteConnect().then(function (result) { - var url = result.lastData - $scope.$apply(function () { - $scope.debugCommand = 'adb connect ' + url + if ($scope.control) { + $scope.control.startRemoteConnect().then(function (result) { + var url = result.lastData + $scope.$apply(function () { + $scope.debugCommand = 'adb connect ' + url + }) }) - }) + + return true + } + return false } // TODO: Remove timeout and fix control initialization - if ($scope.control) { - startRemoteConnect() - } else { - $timeout(startRemoteConnect, 200) + if (!startRemoteConnect()) { + $timeout(function () { + if (!startRemoteConnect()) { + $timeout(startRemoteConnect, 1000) + } + }, 200) } }