Bug Description
The analytics view only shows data from the initial load and doesn't update when changes are made to the donation status of items. Currently, there's no way for users to refresh the analytics data without restarting the app.
Current Behavior
- Analytics data loads when first opening the analytics view
- After marking items as donated/undonated, these changes aren't reflected in the analytics
- There's no refresh button or mechanism to update the analytics view
Steps to Reproduce
- Open the app and navigate to the analytics view
- Note the current donation counts and percentages
- Exit analytics, mark several items as donated
- Return to the analytics view
- Observe that the analytics data hasn't updated to include the new donations
Expected Behavior
Either:
- The analytics view should automatically refresh when it becomes visible again, or
- A refresh button should be provided to allow users to manually update the analytics data
Possible Causes
In AnalyticsDashboardView.swift, data is only loaded on onAppear and when the currentTown changes, but not when returning to the view after making changes:
.onAppear {
loadData()
}
.onChange(of: dataManager.currentTown) { _, _ in
loadData()
}
Additionally, when marking items as donated, the analytics cache might not be properly invalidated.
Proposed Fix
- Add a refresh button to the
AnalyticsDashboardView toolbar:
.toolbar {
ToolbarItem {
Button(action: {
loadData()
}) {
Image(systemName: "arrow.clockwise")
}
}
}
- Ensure proper cache invalidation in
DataManager.swift when donation status changes:
// In all updateXXXDonationStatus methods:
analyticsService.invalidateCache()
Priority
Medium - Affects functionality but there's a workaround (restarting the app)
Bug Description
The analytics view only shows data from the initial load and doesn't update when changes are made to the donation status of items. Currently, there's no way for users to refresh the analytics data without restarting the app.
Current Behavior
Steps to Reproduce
Expected Behavior
Either:
Possible Causes
In
AnalyticsDashboardView.swift, data is only loaded ononAppearand when thecurrentTownchanges, but not when returning to the view after making changes:Additionally, when marking items as donated, the analytics cache might not be properly invalidated.
Proposed Fix
AnalyticsDashboardViewtoolbar:DataManager.swiftwhen donation status changes:Priority
Medium - Affects functionality but there's a workaround (restarting the app)