From 35720d0e8ede7defc3965694b1dbf8438a183721 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 28 Mar 2018 01:13:42 -0700 Subject: [PATCH] Ensure revived hosts have a valid unique ID --- static/js/index.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 2ba3e1b..7ed9244 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -222,6 +222,19 @@ function moduleDidLoad() { console.error('%c[index.js, moduleDidLoad]', 'color: green;', 'Failed httpInit! Returned error was: ', failedInit); }); } + + // load previously connected hosts, which have been killed into an object, and revive them back into a class + chrome.storage.sync.get('hosts', function(previousValue) { + hosts = previousValue.hosts != null ? previousValue.hosts : {}; + for(var hostUID in hosts) { // programmatically add each new host. + var revivedHost = new NvHTTP(hosts[hostUID].address, myUniqueid, hosts[hostUID].userEnteredAddress); + revivedHost.serverUid = hosts[hostUID].serverUid; + revivedHost.externalIP = hosts[hostUID].externalIP; + revivedHost.hostname = hosts[hostUID].hostname; + addHostToGrid(revivedHost); + } + console.log('%c[index.js]', 'color: green;', 'Loaded previously connected hosts'); + }); }); }); } @@ -879,19 +892,6 @@ function onWindowLoad(){ $('#bitrateSlider')[0].MaterialSlider.change(previousValue.bitrate != null ? previousValue.bitrate : '10'); updateBitrateField(); }); - - // load previously connected hosts, which have been killed into an object, and revive them back into a class - chrome.storage.sync.get('hosts', function(previousValue) { - hosts = previousValue.hosts != null ? previousValue.hosts : {}; - for(var hostUID in hosts) { // programmatically add each new host. - var revivedHost = new NvHTTP(hosts[hostUID].address, myUniqueid, hosts[hostUID].userEnteredAddress); - revivedHost.serverUid = hosts[hostUID].serverUid; - revivedHost.externalIP = hosts[hostUID].externalIP; - revivedHost.hostname = hosts[hostUID].hostname; - addHostToGrid(revivedHost); - } - console.log('%c[index.js]', 'color: green;', 'Loaded previously connected hosts'); - }); } }