Browse Source

Fix sheet displaying 'None' and empty view

Deniz Cengiz 1 year ago
parent
commit
ca3f2d90ab
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Trio/Sources/Modules/Home/HomeStateModel.swift

+ 5 - 1
Trio/Sources/Modules/Home/HomeStateModel.swift

@@ -688,7 +688,7 @@ extension Home.StateModel:
 extension Home.StateModel: CompletionDelegate {
 extension Home.StateModel: CompletionDelegate {
     func completionNotifyingDidComplete(_ notifying: CompletionNotifying) {
     func completionNotifyingDidComplete(_ notifying: CompletionNotifying) {
         debug(.service, "Completion fired by: \(type(of: notifying))")
         debug(.service, "Completion fired by: \(type(of: notifying))")
-        shouldDisplayCGMSetupSheet = false
+        var wasDeleted: Bool = false
 
 
         if notifying is CGMSetupCompletionNotifying || notifying is CGMDeletionCompletionNotifying ||
         if notifying is CGMSetupCompletionNotifying || notifying is CGMDeletionCompletionNotifying ||
             notifying is CGMManagerSettingsNavigationViewController || notifying is any SetupTableViewControllerDelegate ||
             notifying is CGMManagerSettingsNavigationViewController || notifying is any SetupTableViewControllerDelegate ||
@@ -703,6 +703,7 @@ extension Home.StateModel: CompletionDelegate {
                 Task {
                 Task {
                     await fetchGlucoseManager.deleteGlucoseSource()
                     await fetchGlucoseManager.deleteGlucoseSource()
                 }
                 }
+                wasDeleted = false
             } else {
             } else {
                 debug(.service, "CGMSetupCompletionNotifying: CGM Setup Completed")
                 debug(.service, "CGMSetupCompletionNotifying: CGM Setup Completed")
 
 
@@ -716,6 +717,9 @@ extension Home.StateModel: CompletionDelegate {
 
 
             // update glucose source if required
             // update glucose source if required
             DispatchQueue.main.async {
             DispatchQueue.main.async {
+                if wasDeleted {
+                    self.shouldDisplayCGMSetupSheet = false
+                }
                 self.broadcaster.notify(GlucoseObserver.self, on: .main) {
                 self.broadcaster.notify(GlucoseObserver.self, on: .main) {
                     $0.glucoseDidUpdate([])
                     $0.glucoseDidUpdate([])
                 }
                 }