From 7f1caff2e8ba87dd7dc925ef68c02274a8cb8f4c Mon Sep 17 00:00:00 2001 From: "R. Aidan Campbell" Date: Fri, 26 Aug 2016 23:30:46 -0400 Subject: [PATCH] fixed bug in pairing --- static/js/index.js | 20 ++++++++++++-------- static/js/utils.js | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index a0fe019..08d52c0 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -163,14 +163,14 @@ function pairTo(nvhttpHost, onSuccess, onFailure) { var pairingDialog = document.querySelector('#pairingDialog'); $('#pairingDialogText').html('Please enter the number ' + randomNumber + ' on the GFE dialog on the computer. This dialog will be dismissed once complete'); pairingDialog.showModal(); - console.log('sending pairing request to ' + nvhttpHost.address + ' with random number ' + randomNumber); + console.log('sending pairing request to ' + _api.address + ' with random number ' + randomNumber); _api.pair(randomNumber).then(function (paired) { if (!paired) { if (_api.currentGame != 0) { - $('#pairingDialogText').html('Error: ' + nvhttpHost.address + ' is in app. Cannot pair until the app is stopped.'); + $('#pairingDialogText').html('Error: ' + _api.address + ' is in app. Cannot pair until the app is stopped.'); } else { - $('#pairingDialogText').html('Error: failed to pair with ' + nvhttpHost.address + '. failure reason unknown.'); + $('#pairingDialogText').html('Error: failed to pair with ' + _api.address + '. failure reason unknown.'); } console.log('failed API object: '); console.log(_api.toString()); @@ -182,14 +182,14 @@ function pairTo(nvhttpHost, onSuccess, onFailure) { pairingDialog.close(); onSuccess(); }, function (failedPairing) { - snackbarLog('Failed pairing to: ' + nvhttpHost.address); + snackbarLog('Failed pairing to: ' + _api.address); console.log('pairing failed, and returned ' + failedPairing); console.log('failed API object: '); console.log(_api.toString()); onFailure(); }); }, function (failedRefreshInfo) { - snackbarLog('Failed to connect to ' + nvhttpHost.address + '! Are you sure the host is on?'); + snackbarLog('Failed to connect to ' + _api.address + '! Are you sure the host is on?'); console.log('Returned error was: ' + failedRefreshInfo); console.log('failed API object: '); console.log(_api.toString()); @@ -259,9 +259,13 @@ function continueAddHost() { var _nvhttpHost = new NvHTTP(inputHost, myUniqueid, inputHost); pairTo(_nvhttpHost, function() { - addHostToGrid(_nvhttpHost); - saveHosts(); - document.querySelector('#addHostDialog').close(); + _nvhttpHost.refreshServerInfo().then(function (onSuccess) { + addHostToGrid(_nvhttpHost); + saveHosts(); + document.querySelector('#addHostDialog').close(); + }, function (onFailure) { + console.log('FAILURE!'); + }); }, function() { snackbarLog('pairing to ' + inputHost + ' failed!'); diff --git a/static/js/utils.js b/static/js/utils.js index 71568d4..abcb80e 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -150,7 +150,7 @@ NvHTTP.prototype = { return false; } - if(this.serverUid != $root.find('uniqueid').text().trim() && this.serverUid != null) { + if(this.serverUid != $root.find('uniqueid').text().trim() && this.serverUid != "") { // if we received a UID that isn't the one we expected, fail. return false; }