Skip to content

Fix odometer reading not updating after edit#407

Open
mitre88 wants to merge 1 commit intomikaelacaron:devfrom
mitre88:297-fix-odometer-reading-update
Open

Fix odometer reading not updating after edit#407
mitre88 wants to merge 1 commit intomikaelacaron:devfrom
mitre88:297-fix-odometer-reading-update

Conversation

@mitre88
Copy link
Copy Markdown

@mitre88 mitre88 commented Mar 4, 2026

Description

Fixes #297

When editing an odometer reading, the OdometerView was still showing the old value after the EditOdometerReadingView was dismissed. This happened because updateOdometerReading() updated Firestore but did not update the local readings array.

Changes

Updated OdometerViewModel.updateOdometerReading() to sync the local readings array after a successful Firestore write, following the same pattern already used in deleteReading().

How it works

After setData(from:) succeeds, the method now finds the reading by ID in the local array and replaces it with the updated value. This avoids an unnecessary network call while keeping the UI in sync.

Testing

  1. Add a vehicle and an odometer reading
  2. Swipe left on the reading, tap Edit
  3. Change the distance value and tap Update
  4. The OdometerView now shows the updated value immediately

Screenshots

N/A - Logic-only change, no UI modifications.

Update the local readings array after a successful Firestore write
in updateOdometerReading(), following the same pattern used in
deleteReading(). This ensures the OdometerView reflects the updated
value immediately without requiring a network refresh.

Fixes mikaelacaron#297

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mitre88 mitre88 requested a review from mikaelacaron as a code owner March 4, 2026 00:24
@mikaelacaron
Copy link
Copy Markdown
Owner

thanks for working on this! Next time, please comment on the issue that you're working on it, and I'll assign you! I'll review this soon! I've been on holiday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG - Odometer Reading Doesn't Update Properly

2 participants