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) {
|
if (cachedValue) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
@ -281,11 +281,11 @@
|
||||||
return apiClient.getJSON(apiClient.getUrl('System/Endpoint')).then(function (endpoint) {
|
return apiClient.getJSON(apiClient.getUrl('System/Endpoint')).then(function (endpoint) {
|
||||||
if (endpoint.IsInNetwork) {
|
if (endpoint.IsInNetwork) {
|
||||||
return apiClient.getPublicSystemInfo().then(function (info) {
|
return apiClient.getPublicSystemInfo().then(function (info) {
|
||||||
cache[serverAddress] = info.LocalAddress;
|
addToCache(serverAddress, info.LocalAddress);
|
||||||
return info.LocalAddress;
|
return info.LocalAddress;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cache[serverAddress] = serverAddress;
|
addToCache(serverAddress, serverAddress);
|
||||||
return serverAddress;
|
return serverAddress;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -295,9 +295,26 @@
|
||||||
cache = {};
|
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, 'localusersignedin', clearCache);
|
||||||
Events.on(ConnectionManager, 'localusersignedout', clearCache);
|
Events.on(ConnectionManager, 'localusersignedout', clearCache);
|
||||||
setInterval(clearCache, 180000);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getServerAddress: getServerAddress
|
getServerAddress: getServerAddress
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue