diff --git a/static/js/index.js b/static/js/index.js index d478925..642b837 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -425,6 +425,19 @@ function showApps(host) { console.log('Error! Failed to retrieve box art for app ID: ' + app.id + '. Returned value was: ' + failedPromise) console.log('failed host object: '); console.log(host.toString()); + + if ($('#game-' + app.id).length === 0) { + // double clicking the button will cause multiple box arts to appear. + // to mitigate this we ensure we don't add a duplicate. + // This isn't perfect: there's lots of RTTs before the logic prevents anything + $("#game-grid").append($("
", {html:$("", {src: "static/res/no_app_image.png", id: 'game-'+app.id, name: app.title }), class: 'box-art mdl-cell mdl-cell--3-col'}).append($("", {html: app.title, class:"game-title"}))); + $('#game-'+app.id).on('click', function () { + startGame(host, app.id); + }); + + // apply CSS stylization to indicate whether the app is active + stylizeBoxArt(host, app.id); + } }); }); }, function (failedAppList) { diff --git a/static/js/utils.js b/static/js/utils.js index 1fa07fa..f5c9f9d 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -338,7 +338,14 @@ NvHTTP.prototype = { // TODO: unfortunately we do N lookups from storage cache, each of them filling up the memory cache. // once the first round of calls are all made, each subsequent request hits this and returns from memory cache - if (this._memCachedBoxArtArray[appId] !== undefined) { + if (this._memCachedBoxArtArray[appId] === null) { + // This means a previous box art request failed, don't try again + return new Promise(function (resolve, reject) { + console.log('returning cached box art failure result'); + reject(null); + return; + }.bind(this)); + } else if (this._memCachedBoxArtArray[appId] !== undefined) { return new Promise(function (resolve, reject) { console.log('returning memory cached box art'); resolve(this._memCachedBoxArtArray[appId]); @@ -392,9 +399,13 @@ NvHTTP.prototype = { console.log('returning streamed box art'); resolve(streamedBoxArt); return; + }.bind(this), function(error) { + // Cache the failure but not persistently + this._memCachedBoxArtArray[appId] = null; + console.log('box art request failed'); + reject(error); + return; }.bind(this)); - - }.bind(this)); }.bind(this)); diff --git a/static/res/no_app_image.png b/static/res/no_app_image.png new file mode 100755 index 0000000..4cbad3e Binary files /dev/null and b/static/res/no_app_image.png differ