Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,14 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas
do {
try WCSession.default.sendCarbEntryMessage(entry,
replyHandler: { (suggestion) in
WKExtension.shared().rootInterfaceController?.presentController(withName: BolusInterfaceController.className, context: suggestion)
DispatchQueue.main.async {
WKExtension.shared().rootInterfaceController?.presentController(withName: BolusInterfaceController.className, context: suggestion)
}
},
errorHandler: { (error) in
ExtensionDelegate.shared().present(error)
DispatchQueue.main.async {
ExtensionDelegate.shared().present(error)
}
}
)
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ final class BolusInterfaceController: WKInterfaceController, IdentifiableClass {

do {
try WCSession.default.sendBolusMessage(bolus) { (error) in
ExtensionDelegate.shared().present(error)
DispatchQueue.main.async {
ExtensionDelegate.shared().present(error)
}
}
} catch {
presentAlert(
Expand Down
29 changes: 17 additions & 12 deletions WatchApp Extension/Controllers/StatusInterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,29 +244,34 @@ final class StatusInterfaceController: WKInterfaceController, ContextUpdatable {
do {
try WCSession.default.sendGlucoseRangeScheduleOverrideMessage(userInfo,
replyHandler: { _ in
self.pendingMessageResponses -= 1
if self.pendingMessageResponses == 0 {
self.updateForOverrideContext(userInfo?.context)
DispatchQueue.main.async {
self.pendingMessageResponses -= 1
if self.pendingMessageResponses == 0 {
self.updateForOverrideContext(userInfo?.context)
}
self.lastOverrideContext = userInfo?.context
}
self.lastOverrideContext = userInfo?.context
},
errorHandler: { error in
self.pendingMessageResponses -= 1
if self.pendingMessageResponses == 0 {
self.updateForOverrideContext(self.lastOverrideContext)
DispatchQueue.main.async {
self.pendingMessageResponses -= 1
if self.pendingMessageResponses == 0 {
self.updateForOverrideContext(self.lastOverrideContext)
}
ExtensionDelegate.shared().present(error)
}
ExtensionDelegate.shared().present(error)
}
)
} catch {
pendingMessageResponses -= 1
if pendingMessageResponses == 0 {
updateForOverrideContext(lastOverrideContext)
}
presentAlert(withTitle: NSLocalizedString("Send Failed", comment: "The title of the alert controller displayed after a glucose range override send attempt fails"),
message: NSLocalizedString("Make sure your iPhone is nearby and try again", comment: "The recovery message displayed after a glucose range override send attempt fails"),
preferredStyle: .alert,
actions: [WKAlertAction.dismissAction()]
presentAlert(
withTitle: NSLocalizedString("Send Failed", comment: "The title of the alert controller displayed after a glucose range override send attempt fails"),
message: NSLocalizedString("Make sure your iPhone is nearby and try again", comment: "The recovery message displayed after a glucose range override send attempt fails"),
preferredStyle: .alert,
actions: [WKAlertAction.dismissAction()]
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion WatchApp Extension/ExtensionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ final class ExtensionDelegate: NSObject, WKExtensionDelegate {

extension ExtensionDelegate: WCSessionDelegate {
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
if activationState == .activated && lastContext == nil {
if activationState == .activated {
updateContext(session.receivedApplicationContext)
}
}
Expand Down