fix: GoalsViewModel use repo.loadDay instead of missing goals()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import Foundation
|
||||
|
||||
@MainActor @Observable
|
||||
final class GoalsViewModel {
|
||||
var goal: DailyGoal = .defaultGoal
|
||||
var goal: DailyGoal = DailyGoal()
|
||||
var isLoading = true
|
||||
var errorMessage: String?
|
||||
|
||||
@@ -11,13 +11,11 @@ final class GoalsViewModel {
|
||||
func load() async {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
|
||||
do {
|
||||
goal = try await repo.goals(for: Date().apiDateString, forceRefresh: true)
|
||||
} catch {
|
||||
errorMessage = error.localizedDescription
|
||||
await repo.loadDay(date: Date().apiDateString)
|
||||
goal = repo.goals
|
||||
if let err = repo.error {
|
||||
errorMessage = err
|
||||
}
|
||||
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user