Fix SharedPreferences key/type mismatches and upgrade safety#10
Closed
timbortnik wants to merge 1 commit intomainfrom
Closed
Fix SharedPreferences key/type mismatches and upgrade safety#10timbortnik wants to merge 1 commit intomainfrom
timbortnik wants to merge 1 commit intomainfrom
Conversation
- Read saved_* (Long, user intent) instead of cached_* (Float) in WeatherFetcher, with fallback to cached_* for upgrade compatibility - Decode home_widget doubles correctly: getLong() + Double.fromBits() - Persist GPS coordinates in _loadWeather for background refresh - Add race condition check: discard stale fetch if location changed - Migrate location_source → saved_location_source, remove use_gps - Clear stale city when saveLocation called without city - Skip redundant writes when coordinates unchanged - Remove dead getSavedLocationFromWidget() method - Document SharedPreferences keys and upgrade safety pattern Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
|
Will revisit later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
saved_*(user intent) instead ofcached_*withfallback to legacy
cached_*Float keys for upgrade compatibilityhome_widgetdoubles viagetLong()+Double.fromBits()instead ofgetFloat()_loadWeathernow persists GPS coordinates to HomeWidget so backgroundrefresh (AlarmManager, WorkManager) has coordinates to use
location_source→saved_location_source, removes redundantuse_gpskey,cleans both SharedPreferences and HomeWidget stores
saveLocation()removes stale city when called without one (e.g.switching from manual to GPS)
getSavedLocationFromWidget()Upgrade safety
main.darthandles key renames (idempotent, runs on app open)getLocation()bridges GPS users who haven't opened the app post-upgradesaveLocation()skips redundant writes when nothing changedNote
This is a significant refactor for what were mostly latent issues (the old cached_* Float
round-trip worked in practice). The main real-world fixes are the 0,0 coordinate bug and the
race condition. Consider whether the complexity is warranted.
Test plan
make analyze— no issuesmake test— all Dart + Kotlin tests passapp
🤖 Generated with Claude Code