new ui 12
This commit is contained in:
@@ -286,8 +286,11 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load initial states
|
// Load all device states at once
|
||||||
await loadDeviceStates(roomDevices.map(d => d.device_id));
|
const allStates = await window.apiClient.getAllStates();
|
||||||
|
roomDevices.forEach(device => {
|
||||||
|
deviceStates[device.device_id] = allStates[device.device_id] || null;
|
||||||
|
});
|
||||||
|
|
||||||
// Render devices
|
// Render devices
|
||||||
grid.style.display = 'grid';
|
grid.style.display = 'grid';
|
||||||
@@ -310,23 +313,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDeviceStates(deviceIds) {
|
|
||||||
try {
|
|
||||||
// Load states for all devices using API client
|
|
||||||
const statePromises = deviceIds.map(async deviceId => {
|
|
||||||
try {
|
|
||||||
const state = await window.apiClient.getDeviceState(deviceId);
|
|
||||||
deviceStates[deviceId] = state;
|
|
||||||
} catch (e) {
|
|
||||||
console.warn(`Failed to load state for ${deviceId}:`, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await Promise.all(statePromises);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error loading device states:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDeviceCard(device) {
|
function createDeviceCard(device) {
|
||||||
const card = document.createElement('a');
|
const card = document.createElement('a');
|
||||||
card.className = 'device-card';
|
card.className = 'device-card';
|
||||||
|
|||||||
Reference in New Issue
Block a user