Nightscout follower now syncs every 15s and sync button removed from treatments screen
This commit is contained in:
parent
9b9fcef5ba
commit
dd25cd78e2
|
@ -195,7 +195,7 @@ class NightScoutFollowManager:NSObject {
|
|||
}
|
||||
|
||||
// schedule new download
|
||||
self.scheduleNewDownload(followGlucoseDataArray: &followGlucoseDataArray)
|
||||
self.scheduleNewDownload()
|
||||
|
||||
}
|
||||
|
||||
|
@ -208,28 +208,13 @@ class NightScoutFollowManager:NSObject {
|
|||
|
||||
}
|
||||
|
||||
/// wel schedule new download with timer, when timer expires download() will be called
|
||||
/// - parameters:
|
||||
/// - followGlucoseDataArray : array of FollowGlucoseData, first element is the youngest, can be empty. This is the data downloaded during previous download. This parameter is just there to get the timestamp of the latest reading, in order to calculate the next download time
|
||||
private func scheduleNewDownload(followGlucoseDataArray:inout [NightScoutBgReading]) {
|
||||
/// schedule new download with timer, when timer expires download() will be called
|
||||
private func scheduleNewDownload() {
|
||||
|
||||
trace("in scheduleNewDownload", log: self.log, category: ConstantsLog.categoryNightScoutFollowManager, type: .info)
|
||||
|
||||
// start with timestamp now + 5 minutes and 10 seconds
|
||||
var nextFollowDownloadTimeStamp = Date(timeIntervalSinceNow: 5 * 60 + 10)
|
||||
|
||||
// followGlucoseDataArray.count > 0 then use the timestamp of the latest reading to calculate the next downloadtimestamp
|
||||
if followGlucoseDataArray.count > 0 {
|
||||
// use timestamp of latest stored reading + 5 minutes + 10 seconds
|
||||
nextFollowDownloadTimeStamp = Date(timeInterval: 5 * 60 + 10, since: followGlucoseDataArray[0].timeStamp)
|
||||
// now increase till next timestamp is bigger than now
|
||||
while (nextFollowDownloadTimeStamp < Date()) {
|
||||
nextFollowDownloadTimeStamp = Date(timeInterval: 5 * 60, since: nextFollowDownloadTimeStamp)
|
||||
}
|
||||
}
|
||||
|
||||
// schedule timer and assign it to a let property
|
||||
let downloadTimer = Timer.scheduledTimer(timeInterval: nextFollowDownloadTimeStamp.timeIntervalSince1970 - Date().timeIntervalSince1970, target: self, selector: #selector(self.download), userInfo: nil, repeats: false)
|
||||
// schedule a timer for 15 seconds and assign it to a let property
|
||||
let downloadTimer = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.download), userInfo: nil, repeats: false)
|
||||
|
||||
// assign invalidateDownLoadTimerClosure to a closure that will invalidate the downloadTimer
|
||||
invalidateDownLoadTimerClosure = {
|
||||
|
|
|
@ -233,12 +233,6 @@
|
|||
</view>
|
||||
<tabBarItem key="tabBarItem" title="Treatments" image="Home" id="EM7-TR-8Pt"/>
|
||||
<navigationItem key="navigationItem" title="Treatments" id="fUA-gv-91n">
|
||||
<barButtonItem key="leftBarButtonItem" image="arrow.clockwise.icloud" catalog="system" id="eLq-m9-bla">
|
||||
<color key="tintColor" red="0.96848052740000001" green="0.89723356880000005" blue="0.24125458929999999" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
||||
<connections>
|
||||
<action selector="syncButtonTapped:" destination="01q-Jv-AjA" id="EeF-H4-ZK3"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="add" id="iA1-b8-F3J">
|
||||
<color key="tintColor" systemColor="systemYellowColor"/>
|
||||
<connections>
|
||||
|
@ -1968,7 +1962,6 @@
|
|||
<image name="Home" width="30" height="30"/>
|
||||
<image name="Settings" width="30" height="30"/>
|
||||
<image name="Treatments" width="30" height="30"/>
|
||||
<image name="arrow.clockwise.icloud" catalog="system" width="128" height="88"/>
|
||||
<image name="chevron.backward" catalog="system" width="96" height="128"/>
|
||||
<image name="chevron.forward" catalog="system" width="96" height="128"/>
|
||||
<image name="ellipsis.circle" catalog="system" width="128" height="121"/>
|
||||
|
|
|
@ -28,14 +28,6 @@ class TreatmentsViewController : UIViewController {
|
|||
|
||||
@IBOutlet weak var tableView: UITableView!
|
||||
|
||||
/// Sync button action.
|
||||
@IBAction func syncButtonTapped(_ sender: UIBarButtonItem) {
|
||||
|
||||
// nightscout upload manager observes this value and will initialize a sync
|
||||
UserDefaults.standard.nightScoutSyncTreatmentsRequired = true
|
||||
|
||||
}
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
|
Loading…
Reference in New Issue