mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update chromecast address
This commit is contained in:
parent
887ea2afc1
commit
183854ff5f
1 changed files with 21 additions and 4 deletions
|
@ -270,7 +270,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
var cachedValue = cache[serverAddress];
|
||||
var cachedValue = getCachedValue(serverAddress);
|
||||
if (cachedValue) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
|
@ -281,11 +281,11 @@
|
|||
return apiClient.getJSON(apiClient.getUrl('System/Endpoint')).then(function (endpoint) {
|
||||
if (endpoint.IsInNetwork) {
|
||||
return apiClient.getPublicSystemInfo().then(function (info) {
|
||||
cache[serverAddress] = info.LocalAddress;
|
||||
addToCache(serverAddress, info.LocalAddress);
|
||||
return info.LocalAddress;
|
||||
});
|
||||
} else {
|
||||
cache[serverAddress] = serverAddress;
|
||||
addToCache(serverAddress, serverAddress);
|
||||
return serverAddress;
|
||||
}
|
||||
});
|
||||
|
@ -295,9 +295,26 @@
|
|||
cache = {};
|
||||
}
|
||||
|
||||
function addToCache(key, value) {
|
||||
cache[key] = {
|
||||
value: value,
|
||||
time: new Date().getTime()
|
||||
};
|
||||
}
|
||||
|
||||
function getCachedValue(key) {
|
||||
|
||||
var obj = cache[key];
|
||||
|
||||
if (obj && (new Date().getTime() - obj.time) < 180000) {
|
||||
return obj.value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Events.on(ConnectionManager, 'localusersignedin', clearCache);
|
||||
Events.on(ConnectionManager, 'localusersignedout', clearCache);
|
||||
setInterval(clearCache, 180000);
|
||||
|
||||
return {
|
||||
getServerAddress: getServerAddress
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue