Skip to content

Do not refresh providers unnecessarily when app state changes#3025

Merged
veloce merged 6 commits into
mainfrom
fix_connectivity_changes
Apr 20, 2026
Merged

Do not refresh providers unnecessarily when app state changes#3025
veloce merged 6 commits into
mainfrom
fix_connectivity_changes

Conversation

@veloce

@veloce veloce commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

That fixes an issue where network requests were made for nothing when the app was put into background/resumed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from connectivityChangesProvider but selecting only isOnline.
  • Replaced many connectivityChangesProvider usages with onlineStatusProvider (including .future awaits 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.

Comment thread lib/src/network/connectivity.dart Outdated
Comment thread lib/src/network/connectivity.dart Outdated
Comment thread lib/src/view/user/user_screen.dart Outdated
Comment thread lib/src/view/user/recent_games.dart Outdated
veloce and others added 5 commits April 20, 2026 12:06
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]>
@veloce veloce merged commit 4de8ae2 into main Apr 20, 2026
1 check passed
@veloce veloce deleted the fix_connectivity_changes branch April 20, 2026 11:40
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.

2 participants