Skip to content

Commit daa8ed4

Browse files
committed
Bugfix: fix crashes and fix UI issue
1 parent c86a735 commit daa8ed4

4 files changed

Lines changed: 9 additions & 38 deletions

File tree

InfiniLink/BLE/DeviceManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class DeviceManager: ObservableObject {
216216
extension DeviceManager {
217217
func updateInfo(characteristic: CBCharacteristic) {
218218
guard let value = characteristic.value else { return }
219+
guard bleManager.pairedDevice != nil else { return }
219220

220221
bleManager.pairedDevice.bleUUID = characteristic.uuid.uuidString
221222

InfiniLink/Core/Components/Charts/EmptyChartView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct EmptyChartView: View {
4848

4949
var body: some View {
5050
ZStack {
51-
Rectangle()
51+
RoundedRectangle(cornerRadius: 11)
5252
.stroke(backgroundColor, lineWidth: 1)
5353
HStack(spacing: 0) {
5454
ForEach(1...4, id: \.self) { _ in

InfiniLink/Core/Welcome/SetUpDetailsView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ struct SetUpDetailsView: View {
134134
}
135135
}
136136
.onAppear {
137-
self.weight = String(personalizationController.calculatedWeight)
138-
self.height = String(personalizationController.calculatedHeight)
137+
if let weight = personalizationController.weight, weight > 0 {
138+
self.weight = String(personalizationController.calculatedWeight)
139+
}
140+
if let height = personalizationController.height, height > 0 {
141+
self.height = String(personalizationController.calculatedHeight)
142+
}
139143
}
140144
.onDisappear {
141145
if personalizationController.units == .imperial {

InfiniLink/Utils/PersistenceController.swift

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,10 @@ struct PersistenceController {
1414

1515
init() {
1616
container = NSPersistentContainer(name: "InfiniLink")
17-
let storeURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.alexemry.Infini-iOS")!.appendingPathComponent("InfiniLink.sqlite") // This is where we want to store the new database so widgets will be able to access it
18-
19-
var defaultURL: URL?
20-
if let storeDescription = container.persistentStoreDescriptions.first, let url = storeDescription.url {
21-
defaultURL = FileManager.default.fileExists(atPath: url.path) ? url : nil
22-
}
23-
24-
// If we haven't migrated yet, load the current stores
25-
if defaultURL == nil {
26-
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: storeURL)]
27-
}
28-
container.loadPersistentStores { [self] storeDescription, error in
17+
container.loadPersistentStores { storeDescription, error in
2918
storeDescription.shouldMigrateStoreAutomatically = true
3019
storeDescription.shouldInferMappingModelAutomatically = true
3120

32-
if let url = defaultURL {
33-
let coordinator = container.persistentStoreCoordinator
34-
35-
// Get the store object for the unmigrated database
36-
if let oldStore = coordinator.persistentStore(for: url) {
37-
do {
38-
let _ = try coordinator.migratePersistentStore(oldStore, to: storeURL, type: .sqlite)
39-
40-
// Create a coordinator to delete the old store
41-
let fileCoordinator = NSFileCoordinator(filePresenter: nil)
42-
fileCoordinator.coordinate(writingItemAt: url, options: .forDeleting, error: nil) { url in
43-
do {
44-
try FileManager.default.removeItem(at: url)
45-
} catch {
46-
log(error.localizedDescription, caller: "PersistenceController")
47-
}
48-
}
49-
} catch {
50-
log(error.localizedDescription, caller: "PersistenceController")
51-
}
52-
}
53-
}
54-
5521
if let error = error as NSError? {
5622
fatalError("Unresolved error \(error), \(error.userInfo)")
5723
}

0 commit comments

Comments
 (0)