Do not refresh providers unnecessarily when app state changes#3025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces unnecessary provider recomputation (and resulting network requests) when the app transitions between background/resumed by introducing a dedicated online/offline provider and migrating call sites to it.
Changes:
- Added
onlineStatusProvider, derived fromconnectivityChangesProviderbut selecting onlyisOnline. - Replaced many
connectivityChangesProviderusages withonlineStatusProvider(including.futureawaits in model providers). - Updated UI gating logic (e.g., offline banners, feature visibility) to depend on
AsyncValue<bool>rather than the full connectivity status tuple.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/network/connectivity.dart | Adds onlineStatusProvider and documents preferring it for online checks. |
| lib/src/widgets/feedback.dart | Offline banner now depends on onlineStatusProvider. |
| lib/src/view/watch/watch_tab_screen.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/user/user_screen.dart | Uses onlineStatusProvider for passing online state to routes. |
| lib/src/view/user/recent_games.dart | Uses onlineStatusProvider for route parameter isOnline. |
| lib/src/view/settings/settings_screen.dart | Uses onlineStatusProvider instead of selecting from connectivity status. |
| lib/src/view/puzzle/puzzle_themes_screen.dart | Uses onlineStatusProvider.future to avoid recomputation on lifecycle-only updates. |
| lib/src/view/puzzle/puzzle_tab_screen.dart | Uses onlineStatusProvider for online gating in puzzle UI. |
| lib/src/view/puzzle/puzzle_screen.dart | Uses onlineStatusProvider for online-dependent settings UI. |
| lib/src/view/puzzle/opening_screen.dart | Uses onlineStatusProvider.future in openings loader provider. |
| lib/src/view/play/quick_game_matrix.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/play/play_menu.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/play/create_game_widget.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/more/more_tab_screen.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/learn/learn_tab_screen.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/home/home_tab_screen.dart | Uses onlineStatusProvider to avoid rebuild-triggered refresh on app state changes. |
| lib/src/view/account/profile_screen.dart | Uses onlineStatusProvider for online gating. |
| lib/src/view/account/account_drawer.dart | Uses onlineStatusProvider for online gating. |
| lib/src/model/game/game_history.dart | Uses onlineStatusProvider.future to prevent provider refresh on lifecycle-only changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
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.
That fixes an issue where network requests were made for nothing when the app was put into background/resumed.