From d19bc0ca7d101c7f6b98ef3d1951b00ec34fad95 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 24 Dec 2018 18:13:31 -0800 Subject: [PATCH] Fix adding PCs that are already paired --- static/js/index.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 113e812..be62110 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -339,20 +339,30 @@ function addHost() { var inputHost = $('#dialogInputHost').val(); var _nvhttpHost = new NvHTTP(inputHost, myUniqueid, inputHost); - pairTo(_nvhttpHost, function() { - // Check if we already have record of this host + _nvhttpHost.refreshServerInfoAtAddress(inputHost).then(function(success) { if (hosts[_nvhttpHost.serverUid] != null) { - // Just update the addresses - hosts[_nvhttpHost.serverUid].address = _nvhttpHost.address; - hosts[_nvhttpHost.serverUid].userEnteredAddress = _nvhttpHost.userEnteredAddress; - } else { - // Host must be in the grid before starting background polling - addHostToGrid(_nvhttpHost); - beginBackgroundPollingOfHost(_nvhttpHost); + _nvhttpHost.ppkstr = hosts[_nvhttpHost.serverUid].ppkstr; } - saveHosts(); - }); - modal.close(); + + modal.close(); + + pairTo(_nvhttpHost, function() { + // Check if we already have record of this host + if (hosts[_nvhttpHost.serverUid] != null) { + // Just update the addresses + hosts[_nvhttpHost.serverUid].address = _nvhttpHost.address; + hosts[_nvhttpHost.serverUid].userEnteredAddress = _nvhttpHost.userEnteredAddress; + } else { + // Host must be in the grid before starting background polling + addHostToGrid(_nvhttpHost); + beginBackgroundPollingOfHost(_nvhttpHost); + } + saveHosts(); + }); + }.bind(this), + function(failure) { + snackbarLog('Failed to connect to ' + _nvhttpHost.hostname + '! Ensure that GameStream is enabled in GeForce Experience.'); + }.bind(this)); }); }