Fix widget gap: forward-fill months and use reference month date for batch update
BatchUpdateView now accepts a saveDate parameter. When saving from a past-month check-in, the call site passes referenceDate.endOfMonth so snapshots are dated within the correct month instead of today. For the current month, Date() is used. Widget forward-fills missing month buckets (trend and category series) using the most recent earlier month's value, preventing gaps when a check-in is done in the following month. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -154,7 +154,8 @@ struct MonthlyCheckInView: View {
|
||||
.sheet(isPresented: $showBatchUpdate) {
|
||||
viewModel.refresh()
|
||||
} content: {
|
||||
BatchUpdateView(sources: viewModel.sources)
|
||||
let batchSaveDate = referenceDate.isSameMonth(as: Date()) ? Date() : referenceDate.endOfMonth
|
||||
BatchUpdateView(sources: viewModel.sources, saveDate: batchSaveDate)
|
||||
}
|
||||
.onChange(of: starRating) { _, newValue in
|
||||
MonthlyCheckInStore.setRating(newValue == 0 ? nil : newValue, for: referenceDate)
|
||||
@@ -945,10 +946,16 @@ struct AchievementMilestoneBar: View {
|
||||
struct BatchUpdateView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
let sources: [InvestmentSource]
|
||||
let saveDate: Date
|
||||
@State private var values: [UUID: String] = [:]
|
||||
@State private var contributions: [UUID: String] = [:]
|
||||
@State private var savedCount = 0
|
||||
|
||||
init(sources: [InvestmentSource], saveDate: Date = Date()) {
|
||||
self.sources = sources
|
||||
self.saveDate = saveDate
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
@@ -1080,7 +1087,7 @@ struct BatchUpdateView: View {
|
||||
|
||||
repository.createSnapshot(
|
||||
for: source,
|
||||
date: Date(),
|
||||
date: saveDate,
|
||||
value: parsed,
|
||||
contribution: parsedContribution
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user