From 0811ff78e1716a7984aaa315bac0b2b4a8de248d Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 7 Nov 2026 11:59:41 +0100 Subject: island: keep the Sonix heart and volume until the player agrees --- desktop/island/SonixPanel.qml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'desktop/island') diff --git a/desktop/island/SonixPanel.qml b/desktop/island/SonixPanel.qml index c884c93..73618d3 100644 --- a/desktop/island/SonixPanel.qml +++ b/desktop/island/SonixPanel.qml @@ -34,11 +34,21 @@ Column { // Position runs locally between polls; each poll resets it. property real pos: 0 - // The heart flips at once; the next poll confirms or reverts it. + // The heart and volume show the local value until a poll agrees, the + // command fails, or overrideExpiry fires. property var favOverride: null Connections { target: Sonix - function onPlayerChanged() { panel.pos = Sonix.player.position || 0; panel.favOverride = null; } + function onPlayerChanged() { + panel.pos = Sonix.player.position || 0; + if (panel.favOverride !== null && !!Sonix.player.favourite === panel.favOverride) panel.favOverride = null; + if (panel.pendingVol >= 0 && !volSend.running && Sonix.player.volume === panel.pendingVol) panel.pendingVol = -1; + } + } + Timer { + id: overrideExpiry + interval: 3000 + onTriggered: { panel.favOverride = null; if (!volSend.running) panel.pendingVol = -1; } } Timer { interval: 1000; repeat: true @@ -54,8 +64,10 @@ Column { interval: 400 onTriggered: { const v = panel.pendingVol; - panel.pendingVol = -1; - if (v >= 0) Sonix.command({ do: "volume", value: v }, null, panel.report); + if (v < 0) return; + Sonix.command({ do: "volume", value: v }, null, + (ok, d, err) => { panel.report(ok, d, err); if (!ok) panel.pendingVol = -1; }); + overrideExpiry.restart(); } } @@ -68,7 +80,7 @@ Column { readonly property string artUrl: p.path ? `${Sonix.base}/api/art?${S.query({ path: p.path, max: 256 })}&t=${artTry}` : "" readonly property string artPath: p.path || "" - onArtPathChanged: { artTry = 0; artRetry.stop(); } + onArtPathChanged: { artTry = 0; artRetry.stop(); favOverride = null; } Timer { id: artRetry; interval: 1000; onTriggered: panel.artTry++ } spacing: 14 @@ -181,7 +193,9 @@ Column { onClicked: { const want = !heart.fav; panel.favOverride = want; - Sonix.command({ do: "favourite", path: panel.p.path, value: want ? 1 : 0 }, null, panel.report); + overrideExpiry.restart(); + Sonix.command({ do: "favourite", path: panel.p.path, value: want ? 1 : 0 }, null, + (ok, d, err) => { panel.report(ok, d, err); if (!ok) panel.favOverride = null; }); } } } -- cgit v1.2.3