-
Notifications
You must be signed in to change notification settings - Fork 1
fix: skip auto refresh for disabled widgets #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/nav3
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 optimizes widget resource usage by implementing conditional auto-refresh logic that only runs for enabled widgets. The implementation adds lifecycle-aware refresh management through job tracking and widget state observation, while also ensuring preview screens can manually trigger refresh when displayed.
Key changes:
- Widget refresh coroutines now start/stop based on enable/disable state
- Preview screens manually refresh data when displayed via
refreshOnDisplay()methods - Centralized job management using
ConcurrentHashMapto track active widget refresh coroutines
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| WidgetsRepo.kt | Core implementation: replaces unconditional periodic updates with state-aware job management that starts/stops refresh coroutines based on widget enable/disable status |
| WeatherViewModel.kt, PriceViewModel.kt, HeadlinesViewModel.kt, FactsViewModel.kt, BlocksViewModel.kt | Adds refreshOnDisplay() method to each ViewModel for manual refresh triggering |
| WeatherPreviewScreen.kt, PricePreviewScreen.kt, HeadlinesPreviewScreen.kt, FactsPreviewScreen.kt, BlocksPreviewScreen.kt | Adds LaunchedEffect to trigger refresh when preview screen is displayed |
…d-widgets' into fix/skip-autorefresh-for-disabled-widgets
e57eef3 to
1eb159f
Compare
Closes #197
Description
This PR skips the auto refresh for disabled widgets, saving resources
Preview
No visual change
Screen_recording_20251226_111216.webm
QA Notes