Skip to content

Adapt alert call sites to the async LoopKit delegate API - #3

Merged
ps2 merged 1 commit into
next-devfrom
fix/async-alert-call-sites
Aug 31, 2026
Merged

Adapt alert call sites to the async LoopKit delegate API#3
ps2 merged 1 commit into
next-devfrom
fix/async-alert-call-sites

Conversation

@ps2

@ps2 ps2 commented Aug 31, 2026

Copy link
Copy Markdown

next-dev does not currently compile. #2 brought in the alerts rework, which calls PumpManagerDelegate.issueAlert and retractAlert — both async in the tidepool-synced LoopKit — from synchronous closures:

MedtrumPumpManager.swift:903:  error: 'async' call in a function that does not support concurrency
MedtrumKitUICoordinator.swift:288:  error: same
PatchSettingsViewModel.swift:138,139:  error: same

These adaptations were made and verified while preparing #2, but were lost before it was pushed — my error — so the merge landed without them. This restores them.

Follows the pattern already used in OmnipodKit (Task { await …delegate?.issueAlert(…) }):

site calls
MedtrumPumpManager.emitAlert issueAlert, then hasNewPumpEvents
PatchSettingsViewModel retractAlert, then issueAlert
MedtrumKitUICoordinator.pumpRemoval retractAlert

In each case both delegate calls stay inside a single Task so their relative order is preserved. WeakSynchronizedDelegate.notify dispatches its block onto the delegate queue, so these ran sequentially before the API became async. Wrapping only the first would let them race — and in PatchSettingsViewModel that risks issuing the new patch-expiry notification before the old one is retracted, leaving a stale alert.

A sweep confirms no other un-awaited issueAlert/retractAlert call sites remain. Full LoopWorkspace builds.

next-dev does not currently compile. The dev merge (#2) brought in the
alerts rework, which calls PumpManagerDelegate.issueAlert and
retractAlert -- both async in the tidepool-synced LoopKit -- from
synchronous closures:

  MedtrumPumpManager.swift:903: error: 'async' call in a function that
  does not support concurrency
  MedtrumKitUICoordinator.swift:288: error: same
  PatchSettingsViewModel.swift:138,139: error: same

These adaptations were made and verified while preparing #2 but were
lost before it was pushed; the merge landed without them. This restores
them.

Follows the pattern already used in OmnipodKit:

- MedtrumPumpManager.emitAlert -- issueAlert, then hasNewPumpEvents
- PatchSettingsViewModel -- retractAlert, then issueAlert
- MedtrumKitUICoordinator.pumpRemoval -- retractAlert

In each case both delegate calls stay inside a single Task so their
relative order is preserved. WeakSynchronizedDelegate.notify dispatches
its block onto the delegate queue, so these ran sequentially before the
API became async. Wrapping only the first call would let them race, and
in PatchSettingsViewModel that would risk issuing the new patch-expiry
notification before the old one is retracted, leaving a stale alert.

A sweep confirms no other un-awaited issueAlert/retractAlert call sites
remain. Workspace builds.
@ps2
ps2 merged commit 85a61c2 into next-dev Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant