Add aggressive Nightscout polling after remote commands#566
Add aggressive Nightscout polling after remote commands#566
Conversation
After a remote command (bolus, carbs, override, temp target) succeeds, poll Nightscout every 3 seconds for up to 30 seconds to quickly reflect the command on the main screen. Polling stops early when fresh data matching the command type is detected.
|
Instead of starting to poll when the command is sent, I think we should start when we get confirmation that Loop/Trio received and acted on it, there can be a delay between those two points. We should in that case post remoteCommandSucceeded from userNotificationCenter(_:willPresent:). This also naturally limits polling to when the app is in the foreground — if the user has already left the app, polling isn't needed. This would also let us remove all the individual NotificationCenter.default.post(name: .remoteCommandSucceeded) calls from the remote command views, simplifying the code. The only incoming notifications are confirmation and failure notifications, we can improve this in the future, classifying them somehow, but even if we start poll on a fail we would show the gray dot faster. Should we do evaluateRemoteCommandPollingCompletion in devicestatus? All commands are treatments, should not that be enough? |
Summary
remoteCommandSucceedednotification on successExtracted from #558 to keep that PR focused on units/metrics.