v0.8.19
This commit is contained in:
+22
-3
@@ -46,20 +46,37 @@ function updateDevice(device) {
|
||||
if (index >= 0) app.devices[index] = device; else app.devices.push(device);
|
||||
}
|
||||
|
||||
function enqueueZoneControlRequest(id, patch) {
|
||||
const previous = app.zoneControlQueue[id] || Promise.resolve();
|
||||
const request = previous.catch(() => {}).then(() =>
|
||||
api(`/api/zones/${encodeURIComponent(id)}/control`, {method:'POST', body:patch})
|
||||
);
|
||||
app.zoneControlQueue[id] = request;
|
||||
request.finally(() => {
|
||||
if (app.zoneControlQueue[id] === request) delete app.zoneControlQueue[id];
|
||||
}).catch(() => {});
|
||||
return request;
|
||||
}
|
||||
|
||||
async function sendZoneLocalPower(id, power) {
|
||||
const sequence = (app.zoneControlSeq[id] || 0) + 1;
|
||||
app.zoneControlSeq[id] = sequence;
|
||||
try {
|
||||
const zone = await api(`/api/zones/${encodeURIComponent(id)}/control`, {method:'POST', body:{power}});
|
||||
const zone = await enqueueZoneControlRequest(id, {power});
|
||||
if (app.zoneControlSeq[id] !== sequence) return;
|
||||
const index = app.zones.findIndex(item => item.id === zone.id);
|
||||
if (index >= 0) app.zones[index] = zone; else app.zones.push(zone);
|
||||
renderAll(); scheduleControlPlanLoad(); toast(tr('zones.localPowerUpdated'));
|
||||
} catch (error) { toast(error.message, true); }
|
||||
} catch (error) {
|
||||
if (app.zoneControlSeq[id] === sequence) { await loadBootstrap(); toast(error.message, true); }
|
||||
}
|
||||
}
|
||||
|
||||
async function sendZoneControl(id, patch) {
|
||||
const sequence = (app.zoneControlSeq[id] || 0) + 1;
|
||||
app.zoneControlSeq[id] = sequence;
|
||||
try {
|
||||
const zone = await api(`/api/zones/${encodeURIComponent(id)}/control`, {method:'POST', body:patch});
|
||||
const zone = await enqueueZoneControlRequest(id, patch);
|
||||
if (app.zoneControlSeq[id] !== sequence) return;
|
||||
const index = app.zones.findIndex(item => item.id === zone.id);
|
||||
if (index >= 0) app.zones[index] = zone; else app.zones.push(zone);
|
||||
@@ -69,6 +86,7 @@ async function sendZoneControl(id, patch) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function queueZoneTemperature(zone, value, {snapToHalf=true}={}) {
|
||||
const clamped = clamp(value, 8, 30);
|
||||
const next = snapToHalf ? Math.round(clamped * 2) / 2 : Math.round(clamped * 10) / 10;
|
||||
@@ -93,6 +111,7 @@ function beginInlineTemperatureEdit(target) {
|
||||
input.inputMode = 'decimal';
|
||||
input.value = value.toFixed(decimals);
|
||||
input.setAttribute('aria-label', tr('common.targetTemperature'));
|
||||
input.title = tr('common.targetTemperature');
|
||||
target.classList.add('editing');
|
||||
target.replaceChildren(input);
|
||||
input.focus();
|
||||
|
||||
Reference in New Issue
Block a user