fix: improve location switching (cache refresh, debounce, accessibility)#267
Merged
fix: improve location switching (cache refresh, debounce, accessibility)#267
Conversation
- Pass force_refresh=True to get_weather_data when location changes, ensuring fresh data instead of stale cached results - Add logging when set_current_location fails to save, helping diagnose location persistence issues - Fixes #264 (stale weather data after location switch) - Helps diagnose #266 (location not persisting after restart)
…268) wx.ComboBox with CB_READONLY doesn't fire EVT_COMBOBOX when using arrow keys in collapsed state with screen readers (NVDA). Users had to expand the dropdown and press Enter to change locations. wx.Choice fires EVT_CHOICE on every selection change including arrow key navigation, making location switching work intuitively with screen readers.
- Show cached weather data immediately when switching locations, then refresh with fresh data in the background - Pre-warm cache for all saved locations after initial startup fetch, so subsequent switches are instant - Net effect: location switch goes from 2-5s (full API round-trip) to near-instant when cached data exists
- Add 500ms debounce timer on location change events so rapid arrow key presses only trigger one API fetch (for the final selection) - Add generation counter to discard stale fetch results: if the user switches location again before a fetch completes, the old result is silently discarded instead of updating the UI - Allow force_refresh fetches to proceed even when is_updating is set, preventing location switches from being blocked by in-flight fetches
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
Addresses multiple user-reported issues with location switching.
Bug Fixes
set_current_locationfails to save, helping diagnose the reported issue of London always being selected after restartwx.ComboBox(CB_READONLY)withwx.Choice, which fires selection events on arrow key navigation even when collapsed. Screen readers (NVDA) still announce it as a combo box.Performance
Technical Details
refresh_weather_async(force_refresh=True)now supported for location-triggered refreshes_fetch_generationcounter ensures only the most recent fetch updates the UIforce_refreshbypasses theis_updatingguard so location switches aren't blocked by in-flight requestswx.Choice+EVT_CHOICEreplaceswx.ComboBox(CB_READONLY)+EVT_COMBOBOXTesting
Fixes #264, helps diagnose #266, fixes #268