@@ -131,18 +131,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
131131 tableView. backgroundColor = . secondarySystemBackground
132132
133133 tableView. register ( AlertPermissionsDisabledWarningCell . self, forCellReuseIdentifier: AlertPermissionsDisabledWarningCell . className)
134- notificationsCriticalAlertPermissionsViewModel. $showWarning
135- . receive ( on: RunLoop . main)
136- . sink { [ weak self] showWarning in
137- guard let self = self else { return }
138- let isWarningVisible = self . tableView. numberOfRows ( inSection: Section . alertPermissionsDisabledWarning. rawValue) != 0
139- if !showWarning && isWarningVisible {
140- self . tableView. deleteRows ( at: [ IndexPath ( row: 0 , section: Section . alertPermissionsDisabledWarning. rawValue) ] , with: . top)
141- } else if showWarning && !isWarningVisible {
142- self . tableView. insertRows ( at: [ IndexPath ( row: 0 , section: Section . alertPermissionsDisabledWarning. rawValue) ] , with: . top)
143- }
144- }
145- . store ( in: & cancellables)
146134 }
147135
148136 override func didReceiveMemoryWarning( ) {
@@ -337,7 +325,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
337325 }
338326
339327 updateChartDateRange ( )
340- redrawCharts ( )
341328
342329 if case . bolusing = statusRowMode, bolusProgressReporter? . progress. isComplete == true {
343330 refreshContext. update ( with: . status)
@@ -350,6 +337,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
350337 }
351338
352339 guard active && visible && !refreshContext. isEmpty else {
340+ redrawCharts ( )
353341 return
354342 }
355343
@@ -582,7 +570,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
582570 // Show/hide the table view rows
583571 let statusRowMode = self . determineStatusRowMode ( )
584572
585- self . updateHUDandStatusRows ( statusRowMode: statusRowMode, newSize: currentContext. newSize, animated: animated)
573+ self . updateBannerAndHUDandStatusRows ( statusRowMode: statusRowMode, newSize: currentContext. newSize, animated: animated)
586574
587575 self . redrawCharts ( )
588576
@@ -691,8 +679,18 @@ final class StatusTableViewController: LoopChartsTableViewController {
691679
692680 return statusRowMode
693681 }
682+
683+ private func updateBannerRow( animated: Bool ) {
684+ let warningWasVisible = tableView. numberOfRows ( inSection: Section . alertPermissionsDisabledWarning. rawValue) != 0
685+ let showWarning = notificationsCriticalAlertPermissionsViewModel. showWarning
686+ if !showWarning && warningWasVisible {
687+ tableView. deleteRows ( at: [ IndexPath ( row: 0 , section: Section . alertPermissionsDisabledWarning. rawValue) ] , with: animated ? . top : . none)
688+ } else if showWarning && !warningWasVisible {
689+ tableView. insertRows ( at: [ IndexPath ( row: 0 , section: Section . alertPermissionsDisabledWarning. rawValue) ] , with: animated ? . top : . none)
690+ }
691+ }
694692
695- private func updateHUDandStatusRows ( statusRowMode: StatusRowMode , newSize: CGSize ? , animated: Bool ) {
693+ private func updateBannerAndHUDandStatusRows ( statusRowMode: StatusRowMode , newSize: CGSize ? , animated: Bool ) {
696694 let hudWasVisible = self . shouldShowHUD
697695 let statusWasVisible = self . shouldShowStatus
698696
@@ -701,7 +699,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
701699 self . statusRowMode = statusRowMode
702700
703701 if let newSize = newSize {
704- self . landscapeMode = newSize. width > newSize. height
702+ landscapeMode = newSize. width > newSize. height
705703 }
706704
707705 let hudIsVisible = self . shouldShowHUD
@@ -710,12 +708,14 @@ final class StatusTableViewController: LoopChartsTableViewController {
710708 hudView? . cgmStatusHUD? . isVisible = hudIsVisible
711709
712710 tableView. beginUpdates ( )
711+
712+ updateBannerRow ( animated: animated)
713713
714714 switch ( hudWasVisible, hudIsVisible) {
715715 case ( false , true ) :
716- self . tableView. insertRows ( at: [ IndexPath ( row: 0 , section: Section . hud. rawValue) ] , with: animated ? . top : . none)
716+ tableView. insertRows ( at: [ IndexPath ( row: 0 , section: Section . hud. rawValue) ] , with: animated ? . top : . none)
717717 case ( true , false ) :
718- self . tableView. deleteRows ( at: [ IndexPath ( row: 0 , section: Section . hud. rawValue) ] , with: animated ? . top : . none)
718+ tableView. deleteRows ( at: [ IndexPath ( row: 0 , section: Section . hud. rawValue) ] , with: animated ? . top : . none)
719719 default :
720720 break
721721 }
@@ -1069,17 +1069,17 @@ final class StatusTableViewController: LoopChartsTableViewController {
10691069
10701070 switch statusRowMode {
10711071 case . pumpSuspended( let resuming) where !resuming:
1072- updateHUDandStatusRows ( statusRowMode: . pumpSuspended( resuming: true ) , newSize: nil , animated: true )
1072+ updateBannerAndHUDandStatusRows ( statusRowMode: . pumpSuspended( resuming: true ) , newSize: nil , animated: true )
10731073 deviceManager. pumpManager? . resumeDelivery ( ) { ( error) in
10741074 DispatchQueue . main. async {
10751075 if let error = error {
10761076 let alert = UIAlertController ( with: error, title: NSLocalizedString ( " Failed to Resume Insulin Delivery " , comment: " The alert title for a resume error " ) )
10771077 self . present ( alert, animated: true , completion: nil )
10781078 if case . suspended = self . basalDeliveryState {
1079- self . updateHUDandStatusRows ( statusRowMode: . pumpSuspended( resuming: false ) , newSize: nil , animated: true )
1079+ self . updateBannerAndHUDandStatusRows ( statusRowMode: . pumpSuspended( resuming: false ) , newSize: nil , animated: true )
10801080 }
10811081 } else {
1082- self . updateHUDandStatusRows ( statusRowMode: self . determineStatusRowMode ( ) , newSize: nil , animated: true )
1082+ self . updateBannerAndHUDandStatusRows ( statusRowMode: self . determineStatusRowMode ( ) , newSize: nil , animated: true )
10831083 self . refreshContext. update ( with: . insulin)
10841084 self . log. debug ( " [reloadData] after manually resuming suspend " )
10851085 self . reloadData ( )
@@ -1097,7 +1097,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
10971097 show ( vc, sender: tableView. cellForRow ( at: indexPath) )
10981098 }
10991099 case . bolusing:
1100- updateHUDandStatusRows ( statusRowMode: . cancelingBolus, newSize: nil , animated: true )
1100+ updateBannerAndHUDandStatusRows ( statusRowMode: . cancelingBolus, newSize: nil , animated: true )
11011101 deviceManager. pumpManager? . cancelBolus ( ) { ( result) in
11021102 DispatchQueue . main. async {
11031103 switch result {
@@ -1107,9 +1107,9 @@ final class StatusTableViewController: LoopChartsTableViewController {
11071107 case . failure( let error) :
11081108 self . presentErrorCancelingBolus ( error)
11091109 if case . inProgress( let dose) = self . bolusState {
1110- self . updateHUDandStatusRows ( statusRowMode: . bolusing( dose: dose) , newSize: nil , animated: true )
1110+ self . updateBannerAndHUDandStatusRows ( statusRowMode: . bolusing( dose: dose) , newSize: nil , animated: true )
11111111 } else {
1112- self . updateHUDandStatusRows ( statusRowMode: . hidden, newSize: nil , animated: true )
1112+ self . updateBannerAndHUDandStatusRows ( statusRowMode: . hidden, newSize: nil , animated: true )
11131113 }
11141114 }
11151115 }
0 commit comments