This commit is contained in:
Mateusz Gruszczyński
2026-09-16 22:38:45 +02:00
parent bb39ab9dfa
commit e02557bb65
15 changed files with 136 additions and 55 deletions
+31 -2
View File
@@ -584,7 +584,36 @@ function formatDuration(seconds) {
setInterval(() => { if (app.currentView === 'settings') renderSystemInfo(); }, 30000);
async function refreshGreeCloudRuntimeStatus() {
let greeCloudRuntimeStatusCache = null;
let greeCloudRuntimeStatusCachedAt = 0;
let greeCloudRuntimeStatusRequest = null;
const GREE_CLOUD_RUNTIME_STATUS_CACHE_MS = 5000;
function invalidateGreeCloudRuntimeStatusCache() {
greeCloudRuntimeStatusCache = null;
greeCloudRuntimeStatusCachedAt = 0;
}
async function getGreeCloudRuntimeStatus(force = false) {
const now = Date.now();
if (!force && greeCloudRuntimeStatusCache && now - greeCloudRuntimeStatusCachedAt < GREE_CLOUD_RUNTIME_STATUS_CACHE_MS) {
return greeCloudRuntimeStatusCache;
}
if (!force && greeCloudRuntimeStatusRequest) return greeCloudRuntimeStatusRequest;
const request = api('/api/integrations/gree-cloud/status');
if (!force) greeCloudRuntimeStatusRequest = request;
try {
const status = await request;
greeCloudRuntimeStatusCache = status;
greeCloudRuntimeStatusCachedAt = Date.now();
return status;
} finally {
if (greeCloudRuntimeStatusRequest === request) greeCloudRuntimeStatusRequest = null;
}
}
async function refreshGreeCloudRuntimeStatus({ force = false } = {}) {
const summary = $('.cloud-runtime-summary');
if (!summary) return;
const metricSelectors = [
@@ -602,7 +631,7 @@ async function refreshGreeCloudRuntimeStatus() {
const lastContact = $('#greeCloudLastContact');
const lastContactRow = lastContact?.closest('small');
try {
const status = await api('/api/integrations/gree-cloud/status');
const status = await getGreeCloudRuntimeStatus(force);
const runtime = status.runtime || {};
const enabled = status.enabled === true;
const deviceCount = Number(status.device_count || 0);