Conversation
Properly check permissions. Enable background delivery.
|
I think this is ready enough for review. Health will sync now with FreeAPS and FreeAPS will read carbs from health but it will not read deleted carbs from health, if that makes sense. More simply put, carbs can be read and entered from health but if you want to delete it must be done from faps. |
|
@DobbyWanKenoby PTAL |
|
I think it's OK, but we need FAX to Health carbs transfer also |
Added. Wanted to put in in carb storage but that caused a circular dependency. |
|
@dyjaks Good job! You did very good job! We need to add some fix. I finded 2 problem:
I keep checking this problem
|
| CarbsEntry( | ||
| _id: sample.healthKitId, | ||
| createdAt: sample.date, | ||
| carbs: sample.carb as? Decimal ?? 0.0, |
There was a problem hiding this comment.
Conditional downcast from Decimal? to Decimal does nothing
sample.carb is Decimal already
Edit to
carbs: sample.carb ?? 0.0
|
Houston we have a problem Problem with |
|
After a lot of different tests with adding/removing carbs and different situation (such as bad signal), I think, that we shouldn't add carbs to To To At the end of file add |
|
Ok finished review. |
| isa = PBXGroup; | ||
| children = ( | ||
| 38F3783A2613555C009DB701 /* Config.xcconfig */, | ||
| 3818AA42274BBC1100843DB3 /* ConfigOverride.xcconfig */, |
| 3811DEE725CA063400A708ED /* PersistedProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistedProperty.swift; sourceTree = "<group>"; }; | ||
| 3811DF0125CA9FEA00A708ED /* Credentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Credentials.swift; sourceTree = "<group>"; }; | ||
| 3811DF0F25CAAAE200A708ED /* APSManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APSManager.swift; sourceTree = "<group>"; }; | ||
| 3818AA42274BBC1100843DB3 /* ConfigOverride.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigOverride.xcconfig; sourceTree = "<group>"; }; |
There was a problem hiding this comment.
I had same problem in past, when Ivan added ConfigOverride.xcconfig file.
You deleted wrong copy of the file.
Previous version of PR you have 2 files ConfigOverride.xcconfig, one was old (original), and second - new (your).
We need only old file, but now you deleted original.
See checksum (left side) and compare it with original in FreeAPS.xcodeproj/project.pbxproj
freeaps/FreeAPS.xcodeproj/project.pbxproj
Line 483 in b8a0956
You have to return this file, and delete next with checksum '29AC4F65277F48C100766404'
| CURRENT_PROJECT_VERSION = 1; | ||
| DEVELOPMENT_ASSET_PATHS = ""; | ||
| DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}"; | ||
| DEVELOPMENT_TEAM = 4W28235M63; |
There was a problem hiding this comment.
Please return back "${DEVELOPER_TEAM}"
This change automatically with ConfigOverride.xcconfig
| CURRENT_PROJECT_VERSION = 1; | ||
| DEVELOPMENT_ASSET_PATHS = ""; | ||
| DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}"; | ||
| DEVELOPMENT_TEAM = 4W28235M63; |
| CODE_SIGN_STYLE = Automatic; | ||
| CURRENT_PROJECT_VERSION = "$(BUILD_VERSION)"; | ||
| DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}"; | ||
| DEVELOPMENT_TEAM = 4W28235M63; |
| CarbsEntry(createdAt: date, carbs: carbs, enteredBy: CarbsEntry.manual) | ||
| ]) | ||
| let carbArray = [ | ||
| CarbsEntry(id: ID, createdAt: date, carbs: carbs, enteredBy: CarbsEntry.manual) |
There was a problem hiding this comment.
replace to CarbsEntry(createdAt: date, carbs: carbs, enteredBy: CarbsEntry.manual)
In CarbsEntry we added id property with initial value
| import Foundation | ||
|
|
||
| struct CarbsEntry: JSON, Equatable, Hashable { | ||
| let id: String |
There was a problem hiding this comment.
replace to var id = UUID().uuidString
But after adding new property (id) old carbs will not display, and it's a problem.
The reason is because old carbs entities (storing at carbs.json) don't contain id and cant decode.
In several days I will release new MigrationManager and resolve this problem
|
|
||
| extension CarbsEntry { | ||
| private enum CodingKeys: String, CodingKey { | ||
| case id |
There was a problem hiding this comment.
Answer (JSON) from NS have _id field. This is reason because import from NS doesn't work now.
Replace to case id = "_id"
| broadcaster.notify(CarbsObserver.self, on: processQueue) { | ||
| $0.carbsDidUpdate(uniqEvents) | ||
|
|
||
| DispatchQueue.main.async { |
There was a problem hiding this comment.
Why did you fix this code?
I think it must be edit back
| CarbsEntry(id: UUID().uuidString, createdAt: Date(), carbs: Decimal(carbs), enteredBy: CarbsEntry.manual) | ||
| ] | ||
| carbsStorage.storeCarbs(carbArray) | ||
| healthKitManager.saveIfNeeded(carbs: carbArray) |
There was a problem hiding this comment.
Please read comment, where I tell about CarbObserver.
After that these edits are unnecessary
|
New realization in #188 |
Add carbs to healthkit
Should probably refactor carbs/tmp targets to their own files/subscriptions
Entires show up twice in health but health freeapx knows both don't count? All seems to load properly.
Carbs deleted in health don't delete from FreeAPS. Carbs deleted from freeAPS do delete from health.
Most of HealthKitManager.swift is now duplicate code and should be made better but as I don't know swift or ios I'm hitting a limit here of what I can do
Carbs in the future don't show. This is an easy fix but I feel is more a design decision. OpenAPS is not carb forward looking so should they be shown?