Skip to content

Commit

Permalink
[COASTAL-1395] UI flicker (#724)
Browse files Browse the repository at this point in the history
* only update timezone as needed

* redundant request to reloadData

* redundant tableview updates

* use updateBolusProgress instead of reloadData
  • Loading branch information
nhamming authored Nov 6, 2024
1 parent 7119c0b commit 904b8f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Loop/Managers/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ class SettingsManager {
///
/// - Parameter timeZone: The time zone
func setScheduleTimeZone(_ timeZone: TimeZone) {
let shouldUpdate = settings.basalRateSchedule?.timeZone != timeZone ||
settings.carbRatioSchedule?.timeZone != timeZone ||
settings.insulinSensitivitySchedule?.timeZone != timeZone ||
settings.glucoseTargetRangeSchedule?.timeZone != timeZone
guard shouldUpdate else { return }

self.mutateLoopSettings { settings in
settings.basalRateSchedule?.timeZone = timeZone
settings.carbRatioSchedule?.timeZone = timeZone
Expand Down
19 changes: 3 additions & 16 deletions Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
loopManager.startGlucoseValueStalenessTimerIfNeeded()
}
}

private var bolusState: PumpManagerStatus.BolusState = .noBolus {
didSet {
if oldValue != bolusState {
Expand All @@ -307,10 +307,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
default:
break
}
Task { @MainActor in
refreshContext.update(with: .status)
await reloadData(animated: true)
}
}
}
}
Expand Down Expand Up @@ -611,7 +607,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
self.currentCOBDescription = nil
}

self.tableView.beginUpdates()
if let hudView = self.hudView {
// CGM Status
if let glucose = self.loopManager.latestGlucose {
Expand Down Expand Up @@ -641,8 +636,6 @@ final class StatusTableViewController: LoopChartsTableViewController {

redrawCharts()

tableView.endUpdates()

reloading = false
let reloadNow = !self.refreshContext.isEmpty

Expand Down Expand Up @@ -2120,14 +2113,8 @@ extension StatusTableViewController: CompletionDelegate {
extension StatusTableViewController: PumpManagerStatusObserver {
func pumpManager(_ pumpManager: PumpManager, didUpdate status: PumpManagerStatus, oldStatus: PumpManagerStatus) {
log.default("PumpManager:%{public}@ did update status", String(describing: type(of: pumpManager)))
Task { @MainActor in

basalDeliveryState = status.basalDeliveryState
bolusState = status.bolusState

refreshContext.update(with: .status)
await self.reloadData(animated: true)
}
basalDeliveryState = status.basalDeliveryState
bolusState = status.bolusState
}
}

Expand Down

0 comments on commit 904b8f9

Please sign in to comment.