diff --git a/components/wifi-manager/code.js b/components/wifi-manager/code.js index 054ac0ef..6b54a4f4 100644 --- a/components/wifi-manager/code.js +++ b/components/wifi-manager/code.js @@ -643,16 +643,19 @@ function rssiToIcon(rssi){ function refreshAP(force){ if (!enableAPTimer && !force) return; - $.getJSON( "/ap.json", function( data ) { - if(data.length > 0){ - //sort by signal strength - data.sort(function (a, b) { - var x = a["rssi"]; var y = b["rssi"]; - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }); - apList = data; - refreshAPHTML(apList); - } + $.getJSON( "/scan.json", async function( data ) { + await sleep(2000); + $.getJSON( "/ap.json", function( data ) { + if(data.length > 0){ + //sort by signal strength + data.sort(function (a, b) { + var x = a["rssi"]; var y = b["rssi"]; + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); + }); + apList = data; + refreshAPHTML(apList); + } + }); }); } @@ -667,8 +670,8 @@ function refreshAPHTML(data){ } function getMessages() { - $.getJSON("/messages.json?1", function(data) { - data.forEach(function(msg) { + $.getJSON("/messages.json?1", async function(data) { + for (const msg of data) { var msg_age = msg["current_time"] - msg["sent_time"]; var msg_time = new Date(); msg_time.setTime( msg_time.getTime() - msg_age ); @@ -701,7 +704,7 @@ function getMessages() { }); break; case "MESSAGING_CLASS_SYSTEM": - showMessage(msg["message"], msg["type"],msg_age); + var r = await showMessage(msg["message"], msg["type"],msg_age); $("#syslogTable").append( "