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

Remove Download Loop/iAPS Data toggle #297

Merged
merged 2 commits into from
May 13, 2024
Merged
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
6 changes: 3 additions & 3 deletions LoopFollow/Controllers/Timers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extension MainViewController {
@objc func deviceStatusTimerDidEnd(_ timer:Timer) {

// reset timer to 1 minute if settings aren't entered
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
startDeviceStatusTimer(time: 60)
return
}
Expand All @@ -200,7 +200,7 @@ extension MainViewController {


// reset timer to 1 minute if settings aren't entered
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
startTreatmentsTimer(time: 60)
return
}
Expand All @@ -225,7 +225,7 @@ extension MainViewController {
@objc func profileTimerDidEnd(_ timer:Timer) {

// reset timer to 1 minute if settings aren't entered
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
startProfileTimer(time: 60)
return
}
Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/ViewControllers/AlarmViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class AlarmViewController: FormViewController {
func showHideNSDetails() {
var isHidden = false
var isEnabled = true
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
isHidden = true
isEnabled = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GraphSettingsViewController: FormViewController {
func showHideNSDetails() {
var isHidden = false
var isEnabled = true
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
isHidden = true
isEnabled = false
}
Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/ViewControllers/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
func showHideNSDetails() {
var isHidden = false
var isEnabled = true
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
isHidden = true
isEnabled = false
}
Expand Down
23 changes: 6 additions & 17 deletions LoopFollow/ViewControllers/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class SettingsViewController: FormViewController {
func showHideNSDetails() {
var isHidden = false
var isEnabled = true
var isLoopHidden = false;
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
isHidden = true
isEnabled = false
}
Expand Down Expand Up @@ -156,21 +155,21 @@ class SettingsViewController: FormViewController {
if !useTokenUrl {
// Normalize input: remove unwanted characters and lowercase
let filtered = value.replacingOccurrences(of: "[^A-Za-z0-9:/._-]", with: "", options: .regularExpression).lowercased()

// Further clean-up: Remove trailing slashes
var cleanURL = filtered
while cleanURL.last == "/" {
while cleanURL.count > 8 && cleanURL.last == "/" {
cleanURL = String(cleanURL.dropLast())
}

UserDefaultsRepository.url.value = cleanURL
row.value = cleanURL
row.updateCell()
}

self.showHideNSDetails()
globalVariables.nsVerifiedAlert = 0

// Verify Nightscout URL and token
self.checkNightscoutStatus()
}
Expand Down Expand Up @@ -202,16 +201,6 @@ class SettingsViewController: FormViewController {
statusLabelRow = row
row.hidden = "$showNS == false"
}
<<< SwitchRow("loopUser"){ row in
row.title = "Download Loop/iAPS Data"
row.tag = "loopUser"
row.value = UserDefaultsRepository.loopUser.value
row.hidden = "$showNS == false"
}.onChange { row in
guard let value = row.value else { return }
UserDefaultsRepository.loopUser.value = value
}

<<< SwitchRow("showDex"){ row in
row.title = "Show Dexcom Settings"
row.value = UserDefaultsRepository.showDex.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WatchSettingsViewController: FormViewController {
func showHideNSDetails() {
var isHidden = false
var isEnabled = true
if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value {
if UserDefaultsRepository.url.value == "" {
isHidden = true
isEnabled = false
}
Expand Down
1 change: 0 additions & 1 deletion LoopFollow/repository/UserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class UserDefaultsRepository {
static let url = UserDefaultsValue<String>(key: "url", default: "")
static let token = UserDefaultsValue<String>(key: "token", default: "")
static let units = UserDefaultsValue<String>(key: "units", default: "mg/dL")
static let loopUser = UserDefaultsValue<Bool>(key: "loopUser", default: false)

// Dexcom Share Settings
static let showDex = UserDefaultsValue<Bool>(key: "showDex", default: false)
Expand Down