fix: Bugs created after the overhaul, performance and layout fixes

This commit is contained in:
2026-03-08 22:30:56 +02:00
parent 8c15c932b6
commit 6f9fd5cba3
112 changed files with 5771 additions and 970 deletions

View File

@@ -1626,13 +1626,20 @@ export default function DeviceDetail() {
const loadData = async () => {
setLoading(true);
try {
const [d, mqttData] = await Promise.all([api.get(`/devices/${id}`), api.get("/mqtt/status").catch(() => null)]);
// Phase 1: load device from DB immediately — renders page without waiting for MQTT
const d = await api.get(`/devices/${id}`);
setDevice(d);
if (d.staffNotes) setStaffNotes(d.staffNotes);
setLoading(false);
if (mqttData?.devices && d.device_id) {
const match = mqttData.devices.find((s) => s.device_serial === d.device_id);
setMqttStatus(match || null);
// Phase 2: fire async background fetches — do not block the render
if (d.device_id) {
api.get("/mqtt/status").then((mqttData) => {
if (mqttData?.devices) {
const match = mqttData.devices.find((s) => s.device_serial === d.device_id);
setMqttStatus(match || null);
}
}).catch(() => {});
}
setUsersLoading(true);