// LoopFollow // ProfileTask.swift import Foundation extension MainViewController { func scheduleProfileTask(initialDelay: TimeInterval = 3) { let firstRun = Date().addingTimeInterval(initialDelay) TaskScheduler.shared.scheduleTask(id: .profile, nextRun: firstRun) { [weak self] in guard let self = self else { return } self.profileTaskAction() } } func profileTaskAction() { guard IsNightscoutEnabled() else { TaskScheduler.shared.rescheduleTask(id: .profile, to: Date().addingTimeInterval(60)) return } webLoadNSProfile() var interval: TimeInterval = 10 * 60 if NightscoutSocketManager.shared.connectionState == .authenticated { interval = 30 * 60 } TaskScheduler.shared.rescheduleTask(id: .profile, to: Date().addingTimeInterval(interval)) } }