Fix residence detail caching to check both data sources
- APILayer.getResidence() now checks both residences and myResidences caches - Home screen loads myResidences, but getResidence() only checked residences, causing unnecessary network calls on every residence detail visit - Remove flawed iOS-side cache check in TaskViewModel that had race condition with Kotlin StateFlow - let Kotlin handle all caching logic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -300,7 +300,7 @@ class TaskViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
/// Load tasks - either all tasks or filtered by residence
|
||||
/// Checks cache first, then fetches if needed.
|
||||
/// Kotlin's APILayer handles caching - returns cached data if valid without network call.
|
||||
/// - Parameters:
|
||||
/// - residenceId: Optional residence ID to filter by. If nil, loads all tasks.
|
||||
/// - forceRefresh: Whether to bypass cache
|
||||
@@ -309,20 +309,6 @@ class TaskViewModel: ObservableObject {
|
||||
|
||||
currentResidenceId = residenceId
|
||||
tasksError = nil
|
||||
|
||||
// Check if we have cached data and don't need to refresh
|
||||
if !forceRefresh {
|
||||
if let resId = residenceId {
|
||||
if DataManagerObservable.shared.tasksByResidence[resId] != nil {
|
||||
// Data already available via observation, no API call needed
|
||||
return
|
||||
}
|
||||
} else if DataManagerObservable.shared.allTasks != nil {
|
||||
// Data already available via observation, no API call needed
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
isLoadingTasks = true
|
||||
|
||||
// Kick off API call - DataManager will be updated, which updates DataManagerObservable,
|
||||
|
||||
Reference in New Issue
Block a user