revert keepAlive changes from earlier commit

- revert keep alive changes from commit 89b03ec2ee
- correct default data source follower network icon
This commit is contained in:
Paul Plant 2024-03-10 17:27:02 +01:00
parent 3229a0e532
commit c5bc3c11bc
6 changed files with 37 additions and 41 deletions

View File

@ -340,11 +340,11 @@ public class AlertManager:NSObject {
if alertKind == .missedreading {
if let content = content {
// schedule missed reading alert with same content
self.scheduleMissedReadingAlert(snoozePeriodInMinutes: snoozePeriod, content: content)
} else {
} else if UserDefaults.standard.isMaster || (!UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType != .disabled && UserDefaults.standard.activeSensorStartDate != nil) {
_ = self.checkAlertAndFire(alertKind: .missedreading, lastBgReading: nil, lastButOneBgREading: nil, lastCalibration: nil, transmitterBatteryInfo: nil)
@ -555,7 +555,7 @@ public class AlertManager:NSObject {
}
if alertNeeded {
if alertNeeded && (UserDefaults.standard.isMaster || (!UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType != .disabled)) {
// alert needs to be raised
@ -719,9 +719,11 @@ public class AlertManager:NSObject {
return true
} else {
trace("in checkAlert, there's no need to raise alert %{public}@", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, alertKind.descriptionForLogging())
if !UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType == .disabled {
trace("in checkAlert, there's no need to raise alert %{public}@ because we're in follower mode and keep-alive is disabled", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, alertKind.descriptionForLogging())
} else {
trace("in checkAlert, there's no need to raise alert %{public}@", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, alertKind.descriptionForLogging())
}
return false
}
}

View File

@ -315,7 +315,7 @@ class LibreLinkUpFollowManager: NSObject {
}
// schedule new download
//self.scheduleNewDownload()
self.scheduleNewDownload()
}
@ -330,12 +330,7 @@ class LibreLinkUpFollowManager: NSObject {
// rescheduling the timer must be done in main thread
// we do it here at the end of the function so that it is always rescheduled once a valid connection is established, irrespective of whether we get values.
DispatchQueue.main.sync {
// schedule new download, only if followerBackgroundKeepAliveType != disabled
if UserDefaults.standard.followerBackgroundKeepAliveType != .disabled {
self.scheduleNewDownload()
}
self.scheduleNewDownload()
}
}
}
@ -520,6 +515,7 @@ class LibreLinkUpFollowManager: NSObject {
}
print(loginUrl.description)
trace(" in requestLogin, processing login request with URL: %{public}@", log: self.log, category: ConstantsLog.categoryLibreLinkUpFollowManager, type: .info, loginUrl)
guard let url = URL(string: loginUrl) else {
@ -808,15 +804,13 @@ class LibreLinkUpFollowManager: NSObject {
// this will enable the suspension prevention sound playing if background keep-alive is enabled
if UserDefaults.standard.followerBackgroundKeepAliveType != .disabled {
enableSuspensionPrevention()
// do initial download, this will also schedule future downloads
download()
} else {
disableSuspensionPrevention()
}
// do initial download, this will also schedule future downloads
download()
} else {

View File

@ -204,10 +204,8 @@ class NightScoutFollowManager: NSObject {
followerDelegate.followerInfoReceived(followGlucoseDataArray: &followGlucoseDataArray)
}
// schedule new download, only if followerBackgroundKeepAliveType != disabled
//if UserDefaults.standard.followerBackgroundKeepAliveType != .disabled {
self.scheduleNewDownload()
//}
// schedule new download
self.scheduleNewDownload()
}
@ -415,9 +413,7 @@ class NightScoutFollowManager: NSObject {
// this will enable the suspension prevention sound playing if background keep-alive is enabled
if UserDefaults.standard.followerBackgroundKeepAliveType != .disabled {
enableSuspensionPrevention()
} else {
disableSuspensionPrevention()
}

View File

@ -17,9 +17,6 @@ public final class WatchManager: NSObject, ObservableObject {
/// a watch connectivity session instance
private let session: WCSession
// dispatch queue for async processing operations
private let processQueue = DispatchQueue(label: "WatchManager.processQueue")
/// a BgReadingsAccessor instance
private var bgReadingsAccessor: BgReadingsAccessor
@ -58,7 +55,7 @@ public final class WatchManager: NSObject, ObservableObject {
let bgReadings = self.bgReadingsAccessor.getLatestBgReadings(limit: nil, fromDate: Date().addingTimeInterval(-3600 * hoursOfBgReadingsToSend), forSensor: nil, ignoreRawData: true, ignoreCalculatedValue: false)
let slopeOrdinal: Int = bgReadings[0].slopeOrdinal() //? "" : lastReading[0].slopeArrow()
let slopeOrdinal: Int = !bgReadings.isEmpty ? bgReadings[0].slopeOrdinal() : 1
var deltaChangeInMgDl: Double?
@ -151,7 +148,7 @@ extension WatchManager: WCSessionDelegate {
// if the action: refreshBGData message is received, then force the app to send new data to the Watch App
if let requestWatchStateUpdate = message["requestWatchStateUpdate"] as? Bool, requestWatchStateUpdate {
processQueue.async {
DispatchQueue.main.async {
self.sendToWatch()
}
}
@ -161,7 +158,7 @@ extension WatchManager: WCSessionDelegate {
public func sessionReachabilityDidChange(_ session: WCSession) {
if session.isReachable {
processQueue.async {
DispatchQueue.main.async {
self.sendToWatch()
}
}

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<device id="retina6_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
@ -887,9 +886,9 @@
<rect key="frame" x="0.0" y="0.0" width="129" height="128"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="txf-6L-J3o">
<rect key="frame" x="0.0" y="2.3333333333333286" width="18.666666666666668" height="125"/>
<rect key="frame" x="0.0" y="2" width="17" height="123.66666666666667"/>
<color key="tintColor" systemColor="systemGrayColor"/>
<imageReference key="image" image="network.badge.shield.half.filled" catalog="system" symbolScale="small"/>
<imageReference key="image" image="network" catalog="system" symbolScale="small"/>
<preferredSymbolConfiguration key="preferredSymbolConfiguration" configurationType="pointSize" pointSize="18" scale="small"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="VW3-lv-4DN">
@ -2367,7 +2366,7 @@
<image name="drop.fill" catalog="system" width="96" height="128"/>
<image name="ellipsis.circle" catalog="system" width="128" height="123"/>
<image name="lock.circle" catalog="system" width="128" height="123"/>
<image name="network.badge.shield.half.filled" catalog="system" width="128" height="122"/>
<image name="network" catalog="system" width="128" height="123"/>
<image name="questionmark.circle" catalog="system" width="128" height="123"/>
<image name="scope" catalog="system" width="128" height="124"/>
<image name="speaker.wave.2.circle" catalog="system" width="128" height="123"/>

View File

@ -1491,6 +1491,9 @@ final class RootViewController: UIViewController, ObservableObject {
// update data source info
updateDataSourceInfo(animate: false)
// try and reload the widget timeline(s)
WidgetCenter.shared.reloadAllTimelines()
}
nightScoutUploadManager?.uploadLatestBgReadings(lastConnectionStatusChangeTimeStamp: lastConnectionStatusChangeTimeStamp())
@ -1604,7 +1607,7 @@ final class RootViewController: UIViewController, ObservableObject {
// if showReadingInAppBadge = false, means user set it from true to false
// set the app badge to 0. This will cause removal of the badge counter, but also removal of any existing notification on the screen
if !UserDefaults.standard.showReadingInAppBadge {
if !UserDefaults.standard.showReadingInAppBadge || (!UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType == .disabled) {
// applicationIconBadgeNumber has been deprecated for iOS17 but as we currently have a minimum deployment target of iOS15, let's add a conditional check
if #available(iOS 16.0, *) {
@ -1615,6 +1618,11 @@ final class RootViewController: UIViewController, ObservableObject {
}
// make sure that any pending (i.e. already scheduled in the future) missed reading notifications are removed
if !UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType == .disabled {
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [ConstantsNotifications.NotificationIdentifiersForAlerts.missedReadingAlert])
}
// also update Watch App with the new values. (Only really needed for unit change between mg/dl and mmol/l)
watchManager?.updateWatchApp()
@ -2152,8 +2160,8 @@ final class RootViewController: UIViewController, ObservableObject {
// Create Notification Content
let notificationContent = UNMutableNotificationContent()
// set value in badge if required
if UserDefaults.standard.showReadingInAppBadge {
// set value in badge if required and also only if master, or when background keep alive is enabled for followers
if UserDefaults.standard.showReadingInAppBadge && (UserDefaults.standard.isMaster || (!UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType != .disabled)) {
// rescale if unit is mmol
if !UserDefaults.standard.bloodGlucoseUnitIsMgDl {
@ -2196,7 +2204,7 @@ final class RootViewController: UIViewController, ObservableObject {
// notification shouldn't be shown, but maybe the badge counter. Here the badge value needs to be shown in another way and also only if master, or when background keep alive is enabled for followers
if UserDefaults.standard.showReadingInAppBadge {
if UserDefaults.standard.showReadingInAppBadge && (UserDefaults.standard.isMaster || (!UserDefaults.standard.isMaster && UserDefaults.standard.followerBackgroundKeepAliveType != .disabled)) {
// rescale of unit is mmol
readingValueForBadge = readingValueForBadge.mgdlToMmol(mgdl: UserDefaults.standard.bloodGlucoseUnitIsMgDl)