mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Non-functional box art caching
- appears to cache fine in memory - does NOT want to serialize to chrome.storage.local - promises are confusing
This commit is contained in:
parent
88795bc126
commit
e3d000e8ed
@ -22,6 +22,7 @@
|
|||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"storage",
|
"storage",
|
||||||
|
"unlimitedStorage",
|
||||||
"pointerLock",
|
"pointerLock",
|
||||||
"system.network",
|
"system.network",
|
||||||
"fullscreen",
|
"fullscreen",
|
||||||
|
@ -41,6 +41,7 @@ function NvHTTP(address, clientUid) {
|
|||||||
this._baseUrlHttps = 'https://' + address + ':47984';
|
this._baseUrlHttps = 'https://' + address + ':47984';
|
||||||
this._baseUrlHttp = 'http://' + address + ':47989';
|
this._baseUrlHttp = 'http://' + address + ':47989';
|
||||||
this._appListCache = null;
|
this._appListCache = null;
|
||||||
|
this._memCachedBoxArtArray = {};
|
||||||
_self = this;
|
_self = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,13 +143,50 @@ NvHTTP.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getBoxArt: function (appId) {
|
getBoxArt: function (appId) {
|
||||||
return sendMessage('openUrl', [
|
if (chrome.storage) {
|
||||||
_self._baseUrlHttps +
|
// This may be bad practice to push/pull this much data through local storage?
|
||||||
'/appasset?'+_self._buildUidStr() +
|
|
||||||
'&appid=' + appId +
|
return new Promise(function (resolve, reject) {
|
||||||
'&AssetType=2&AssetIdx=0',
|
chrome.storage.local.get('boxArtCache', function(JSONCachedBoxArtArray) {
|
||||||
true
|
var cachedBoxArtArray = JSONCachedBoxArtArray.boxArtArray != undefined ? JSON.parse(JSONCachedBoxArtArray.boxArtArray) : Object
|
||||||
]);
|
var boxArtArray = cachedBoxArtArray.boxArtArray != null ? cachedBoxArtArray.boxArtArray : _self._memCachedBoxArtArray; // yay associative arrays!
|
||||||
|
|
||||||
|
// if we already have it, load from cache
|
||||||
|
if (boxArtArray[appId] != null) {
|
||||||
|
|
||||||
|
resolve(boxArtArray[appId]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, put it in our cache, then return it
|
||||||
|
sendMessage('openUrl', [
|
||||||
|
_self._baseUrlHttps +
|
||||||
|
'/appasset?'+_self._buildUidStr() +
|
||||||
|
'&appid=' + appId +
|
||||||
|
'&AssetType=2&AssetIdx=0',
|
||||||
|
true
|
||||||
|
]).then(function(streamedBoxArt) {
|
||||||
|
// something's going wrong here. the stringified box art renders as "{}"
|
||||||
|
boxArtArray[appId] = streamedBoxArt;
|
||||||
|
var obj = {};
|
||||||
|
obj['boxArtCache'] = JSON.stringify(boxArtArray); // storage is in JSON format. JSON does not support binary data.
|
||||||
|
chrome.storage.local.set(obj, function(onSuccess) {});
|
||||||
|
resolve(streamedBoxArt);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
} else { // shouldn't run because we always have chrome.storage, but I'm not going to antagonize other browsers
|
||||||
|
return sendMessage('openUrl', [
|
||||||
|
_self._baseUrlHttps +
|
||||||
|
'/appasset?'+_self._buildUidStr() +
|
||||||
|
'&appid=' + appId +
|
||||||
|
'&AssetType=2&AssetIdx=0',
|
||||||
|
true
|
||||||
|
]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
launchApp: function (appId, mode, sops, rikey, rikeyid, localAudio, surroundAudioInfo) {
|
launchApp: function (appId, mode, sops, rikey, rikeyid, localAudio, surroundAudioInfo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user