Bring back applist caching and provide a method for the poller to refresh the cache

This commit is contained in:
Cameron Gutman 2016-08-27 13:25:30 -07:00
parent 19d207a4c8
commit 3e66fa2f12

View File

@ -229,7 +229,7 @@ NvHTTP.prototype = {
}); });
}, },
getAppList: function () { getAppListWithCacheFlush: function () {
return sendMessage('openUrl', [this._baseUrlHttps + '/applist?' + this._buildUidStr(), false]).then(function (ret) { return sendMessage('openUrl', [this._baseUrlHttps + '/applist?' + this._buildUidStr(), false]).then(function (ret) {
$xml = this._parseXML(ret); $xml = this._parseXML(ret);
@ -245,10 +245,24 @@ NvHTTP.prototype = {
}); });
} }
this._memCachedApplist = appList;
return appList; return appList;
}.bind(this)); }.bind(this));
}, },
getAppList: function () {
if (this._memCachedApplist) {
return new Promise(function (resolve, reject) {
console.log('returning memory cached app list');
resolve(this._memCachedApplist);
return;
}.bind(this));
}
return this.getAppListWithCacheFlush();
},
// returns the box art of the given appID. // returns the box art of the given appID.
// three layers of response time are possible: memory cached (in javascript), storage cached (in chrome.storage.local), and streamed (host sends binary over the network) // three layers of response time are possible: memory cached (in javascript), storage cached (in chrome.storage.local), and streamed (host sends binary over the network)
getBoxArt: function (appId) { getBoxArt: function (appId) {