Looper UI: re-subscribe polls when the pedal instance changes
The looper timeline and the transport buttons' live captions poll the pedal via SwiftUI `.task`, which captures the pedal at task-start and never re-subscribes. When a rig load swaps in a new LooperPedal instance, the buttons/LEDs (read live in `body`) tracked the new pedal while the polled state text and captions stayed frozen on the old one — the state indicator and "Record/Set End/…" captions never updated even though transport worked. Key the timeline poll on ObjectIdentifier(pedal) (`.task(id:)`) and tag the transport button row with `.id(ObjectIdentifier(pedal))`, so both re-subscribe to the current instance. Board edits reuse the same instance (identity stable), so this only refreshes on an actual instance swap — no per-render churn. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -78,7 +78,9 @@ struct LooperTimelineView: View {
|
||||
track
|
||||
stateIndicator
|
||||
}
|
||||
.task {
|
||||
// Key the poll on the pedal instance: if a rig load / rebuild swaps in a new LooperPedal,
|
||||
// `.task` alone would keep polling the old (captured) instance and freeze. Restart on change.
|
||||
.task(id: ObjectIdentifier(pedal)) {
|
||||
while !Task.isCancelled {
|
||||
position = pedal.playbackPosition01()
|
||||
state = pedal.transportState
|
||||
|
||||
@@ -309,7 +309,10 @@ public struct PedalView: View {
|
||||
knobGrid
|
||||
selectorRow
|
||||
switchRow
|
||||
// Keyed on the pedal instance so the buttons' live captions (which poll the pedal
|
||||
// via `.task`) re-subscribe when a rig load / rebuild swaps in a new pedal instance.
|
||||
transportButtonRow
|
||||
.id(ObjectIdentifier(pedal))
|
||||
buttonRow
|
||||
sliderBank(sliders)
|
||||
Spacer(minLength: 0)
|
||||
|
||||
Reference in New Issue
Block a user