From 0dfbc325418b4914075db25d1ab40ba5fb056aa6 Mon Sep 17 00:00:00 2001 From: marionbarker Date: Sat, 16 Nov 2024 19:04:09 -0800 Subject: [PATCH] update progressCell for bolus display --- Loop/View Controllers/StatusTableViewController.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Loop/View Controllers/StatusTableViewController.swift b/Loop/View Controllers/StatusTableViewController.swift index 6a4aadfcdd..0e14f2167c 100644 --- a/Loop/View Controllers/StatusTableViewController.swift +++ b/Loop/View Controllers/StatusTableViewController.swift @@ -240,10 +240,16 @@ final class StatusTableViewController: LoopChartsTableViewController { didSet { if oldValue != bolusState { switch bolusState { - case .inProgress(_): + case .inProgress(let dose): guard case .inProgress = oldValue else { // Bolus starting bolusProgressReporter = deviceManager.pumpManager?.createBolusProgressReporter(reportingOn: DispatchQueue.main) + // If there is an existing bolus progressCell, update its dose values now in case the app is currently in the + // background as otherwise these values won't get initialized and can contain stale data from some earlier bolus. + if let progressCell = tableView.cellForRow(at: IndexPath(row: StatusRow.status.rawValue, section: Section.status.rawValue)) as? BolusProgressTableViewCell { + progressCell.totalUnits = dose.programmedUnits + progressCell.deliveredUnits = 0 + } break } default: