From de464802cf941113c93f51d5c30ee9e7f090e60c Mon Sep 17 00:00:00 2001 From: "R. Aidan Campbell" Date: Sun, 13 Mar 2016 13:09:09 -0400 Subject: [PATCH] cleaned up some unnecessary NvHTTP calls to make things faster --- static/js/index.js | 18 +++++++++--------- static/js/messages.js | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 7e11cda..da488d4 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -170,13 +170,11 @@ function showAppsMode() { // in theory we should be able to cache the api.currentGame to prevent another call. function gameSelectUpdated() { var currentApp = $("#selectGame").val(); - api.refreshServerInfo().then(function (ret) { - if(api.currentGame == parseInt(currentApp)) { - $("#startGameButton")[0].innerHTML = 'Resume Game' - } else { - $("#startGameButton")[0].innerHTML = 'Run Game' - } - }); + if(api.currentGame == parseInt(currentApp)) { + $("#startGameButton")[0].innerHTML = 'Resume Game' + } else { + $("#startGameButton")[0].innerHTML = 'Run Game' + } } function startSelectedGame() { @@ -286,8 +284,10 @@ function stopGame(callbackFunction) { var appName = runningApp.title; snackbarLog('Stopping ' + appName); api.quitApp().then(function (ret2) { - showAppsMode(); - if (typeof(callbackFunction) === "function") callbackFunction(); + api.refreshServerInfo().then(function (ret3) { // refresh to show no app is currently running. + showAppsMode(); + if (typeof(callbackFunction) === "function") callbackFunction(); + }); }); }); }); diff --git a/static/js/messages.js b/static/js/messages.js index 3ed43fc..6cc7d78 100644 --- a/static/js/messages.js +++ b/static/js/messages.js @@ -21,7 +21,9 @@ function handleMessage(msg) { } else { // else, it's just info, or an event console.log(msg.data); if(msg.data === 'streamTerminated') { // if it's a recognized event, notify the appropriate function - showAppsMode(); + api.refreshServerInfo().then(function (ret) { + showAppsMode(); + }); } } } \ No newline at end of file