Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only store CGM address to user defaults when app is set as "Active CGM", and fix typo in "CGM" #398

Open
wants to merge 5 commits into
base: bjorn
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions xdrip/Extensions/UserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ extension UserDefaults {
/// - stored as data as read from transmitter
case librePatchInfo = "librePatchInfo"

case setActiveGCM = "setActiveGCM"
case setActiveCGM = "setActiveCGM"

}

Expand Down Expand Up @@ -806,12 +806,12 @@ extension UserDefaults {
}
}

@objc dynamic var setActiveGCM: Bool {
@objc dynamic var setActiveCGM: Bool {
get {
return bool(forKey: Key.setActiveGCM.rawValue)
return bool(forKey: Key.setActiveCGM.rawValue)
}
set {
set(newValue, forKey: Key.setActiveGCM.rawValue)
set(newValue, forKey: Key.setActiveCGM.rawValue)
}
}

Expand Down
2 changes: 1 addition & 1 deletion xdrip/Managers/Alerts/AlertManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class AlertManager:NSObject {
/// - if true then an immediate notification is created (immediate being not a future planned, like missed reading), which contains the bg reading in the text - so there's no need to create an additional notificationwith the text in it
public func checkAlerts(maxAgeOfLastBgReadingInSeconds:Double) -> Bool {

if !UserDefaults.standard.setActiveGCM {
if !UserDefaults.standard.setActiveCGM {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion xdrip/Managers/DexcomShare/DexcomShareUploadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DexcomShareUploadManager:NSObject {
/// - lastConnectionStatusChangeTimeStamp : when was the last transmitter dis/reconnect - if nil then 1 1 1970 is used
public func uploadLatestBgReadings(lastConnectionStatusChangeTimeStamp: Date?) {

if !UserDefaults.standard.setActiveGCM {return}
if !UserDefaults.standard.setActiveCGM {return}

// check if dexcomShare is enabled
guard UserDefaults.standard.uploadReadingstoDexcomShare else {
Expand Down
2 changes: 1 addition & 1 deletion xdrip/Managers/Loop/LoopManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class LoopManager:NSObject {
/// share latest readings with Loop
public func share() {

if !UserDefaults.standard.setActiveGCM {return}
if !UserDefaults.standard.setActiveCGM {return}

// unwrap sharedUserDefaults
guard let sharedUserDefaults = sharedUserDefaults else {return}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UIKit
fileprivate enum Setting:Int, CaseIterable {

/// Toggle to set as active CGM for APS and Dexom share upload etc
case setActiveGCM = 0
case setActiveCGM = 0

/// blood glucose unit
case bloodGlucoseUnit = 1
Expand Down Expand Up @@ -63,7 +63,7 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {

switch setting {

case .setActiveGCM:
case .setActiveCGM:
return .nothing

case .bloodGlucoseUnit:
Expand Down Expand Up @@ -149,7 +149,7 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {

switch setting {

case .setActiveGCM:
case .setActiveCGM:
return "Set as active CGM"

case .bloodGlucoseUnit:
Expand Down Expand Up @@ -178,7 +178,7 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {

switch setting {

case .setActiveGCM:
case .setActiveCGM:
return UITableViewCell.AccessoryType.none

case .bloodGlucoseUnit:
Expand All @@ -201,7 +201,7 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {

switch setting {

case .setActiveGCM:
case .setActiveCGM:
return nil

case .bloodGlucoseUnit:
Expand All @@ -224,12 +224,13 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {

switch setting {

case .setActiveGCM:
return UISwitch(isOn: UserDefaults.standard.setActiveGCM, action: {
case .setActiveCGM:
return UISwitch(isOn: UserDefaults.standard.setActiveCGM, action: {
(isOn:Bool) in

UserDefaults.standard.setActiveGCM = isOn
UserDefaults.standard.setActiveCGM = isOn
UserDefaults.standard.showReadingInAppBadge = isOn
UserDefaults.standard.suppressLoopShare = !isOn

if !isOn {
let uNUserNotificationCenter = UNUserNotificationCenter.current()
Expand Down