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
|
@MainActor @Observable
|
||||||
final class GoalsViewModel {
|
final class GoalsViewModel {
|
||||||
var goal: DailyGoal = .defaultGoal
|
var goal: DailyGoal = DailyGoal()
|
||||||
var isLoading = true
|
var isLoading = true
|
||||||
var errorMessage: String?
|
var errorMessage: String?
|
||||||
|
|
||||||
@@ -11,13 +11,11 @@ final class GoalsViewModel {
|
|||||||
func load() async {
|
func load() async {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
errorMessage = nil
|
errorMessage = nil
|
||||||
|
await repo.loadDay(date: Date().apiDateString)
|
||||||
do {
|
goal = repo.goals
|
||||||
goal = try await repo.goals(for: Date().apiDateString, forceRefresh: true)
|
if let err = repo.error {
|
||||||
} catch {
|
errorMessage = err
|
||||||
errorMessage = error.localizedDescription
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user