whyceewhite / CarLess

Logging commuting trips completed using transit or pedestrian modes of transportation.
0 stars 0 forks source link

Kilometer distance unit setting not properly calculating for trips #39

Closed whyceewhite closed 9 years ago

whyceewhite commented 9 years ago

When my distance unit settings is equal to kilometers and I enter a trip, I notice that the Trips listing of the trip does not display the correct mileage. For example:

  1. Distance unit setting is kilometers
  2. Log a manual trip. Set distance to 5 and save.
  3. Go to the Trips list and the entry just created will say 8.05 km instead of 5.
whyceewhite commented 9 years ago

The logging views had a distance unit parameter to calculate the units and display properly. However, since all the views are being loaded on start up, if the distance value changes then the update is not propogated to the views.

This was happening because the distance unit was nil but it returns Mile by default. When I set the setting to Kilometer, the other views already had Mile as the unit and, thus, resulted in the wrong distance value conversions.

Fixed by making the distance unit cached by providing the value in the CaDataManager. Any updates to the setting will automatically be reflected in the cached property. All VCs were updated to use the cached property.