Skip to content

Clear stored predBGs when clearing the OpenAPS forecast#724

Merged
marionbarker merged 1 commit into
devfrom
fix/clear-stale-openaps-forecast
Jul 25, 2026
Merged

Clear stored predBGs when clearing the OpenAPS forecast#724
marionbarker merged 1 commit into
devfrom
fix/clear-stale-openaps-forecast

Conversation

@bjorkert

Copy link
Copy Markdown
Member

Switching from a Trio site to a Loop site left the old Trio forecast lines on the chart until the app was restarted. The switch itself is detected and clearOpenAPSPredictionGraph runs, but the device observer fires right after and calls updateOpenAPSPredictionDisplay, which drew the forecast again from the stored predBGs. Those are only cleared when an openaps record without predBGs arrives, which never happens on a Loop site. This clears the stored predBGs together with the drawn lines and cone, so there is nothing left to redraw from. The Loop to Trio direction already worked. Verified in the simulator against a live Trio and a live Loop site, switching in both directions.

Switching from a Trio site to a Loop site left the old Trio forecast on
the chart. The flip detection in updateDeviceStatusDisplay cleared the
drawn lines and the cone, but the device observer fires right after and
calls updateOpenAPSPredictionDisplay, which redrew the forecast from the
stored predBGs. Those are only cleared when an openaps record without
predBGs arrives, which never happens on a Loop site, so the stale lines
stayed until the app was restarted. Clearing the stored predBGs together
with the drawn data stops the forecast from coming back. The Loop to
Trio direction was already working.
@marionbarker

Copy link
Copy Markdown
Collaborator

I tested the build on two phones, one looking at Loop URL and Trio URL, and Mac Catalyst (Loop URL).

I use separate phones for different URLs so would not have seen this bug.

@marionbarker marionbarker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approve by code review and test build

@marionbarker
marionbarker merged commit f128d24 into dev Jul 25, 2026
1 check passed
@marionbarker
marionbarker deleted the fix/clear-stale-openaps-forecast branch July 25, 2026 00:00
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.

2 participants