v0.14.19
This commit is contained in:
+31
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user