🔇 Remove some print statements, improve comments

pull/8/head
Alexis Drai 2 years ago
parent 644616784a
commit 54fc430dce

@ -18,21 +18,19 @@ struct UnitsManager {
}
mutating func load() async throws {
print("Loading...")
do {
self.units = try await store.load()
print("Units loaded")
} catch {
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to load...")
}
}
func save() async throws {
print("Saving...")
do {
try await store.save(units: units)
print("Units saved")
} catch {
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to save...")
}
}

@ -18,8 +18,8 @@ struct SubjectViewCell: View {
HStack {
VStack {
// FIXME (later, maybe) when getting updated from the UnitView, these two changes are persisted right away instead of waiting for user
// to confirm changes. Or is it rather that we were updating these fields, and then changing the grade, thus calling
// unitsManagerVM.updateUnit(unitVM) ? If so, how to even fix that?
// to confirm changes. They just don't get brought into the main UnitsManager, so the average is not recalculated when a unit's weight changes
// when 'cancel' is hit, it would be nice to reset these two values as well, like a user might expect
HStack {
TextField("", text: $subjectVM.model.name)
.disabled(!unitsManagerVM.isAllEditable)
@ -42,7 +42,8 @@ struct SubjectViewCell: View {
unitVM.updateSubject(subjectVM)
try await unitsManagerVM.updateUnit(unitVM)
} catch {
print("Failed to update grade: \(error)")
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to update grade: \(error)")
}
}
}

@ -89,7 +89,8 @@ struct UnitView: View {
unitVM.updateAllSubjects()
try await unitsManagerVM.updateUnit(unitVM)
} catch {
print("Failed to update unit: \(error)")
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to update unit: \(error)")
}
}
}) {
@ -118,7 +119,8 @@ struct UnitView: View {
try await unitsManagerVM.updateUnit(unitVM)
showingForm = false
} catch {
print("Failed to create unit: \(error)")
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to create unit: \(error)")
}
}
} else {

@ -62,15 +62,14 @@ class UnitsManagerVM : ObservableObject {
}
func load() async throws {
print("Loading VM...")
do {
try await original.load()
DispatchQueue.main.async {
self.model = self.original.data
self.unitsVM = self.original.units.map { UnitVM(unit: $0) }
print("VM loaded")
}
} catch {
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to load VM...")
}
}
@ -79,14 +78,13 @@ class UnitsManagerVM : ObservableObject {
guard let index = unitsVM.firstIndex(where: { $0.id == unitVM.id }) else { return }
let updatedUnit = unitsVM[index].model
original.units[index].update(from: updatedUnit)
print("Saving VM...")
do {
try await original.save()
print("VM saved")
DispatchQueue.main.async {
self.model = self.original.data
}
} catch {
// DEV: this should be replaced with proper error handling before ever going to prod
print("ERROR: Failed to save VM...")
}
}

Loading…
Cancel
Save