Skip to content

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Dec 26, 2025

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

  1. Enable widget → coroutine starts:
  • Enable a widget from settings
  • Check logs - should see "Updated $widgetType widget successfully]"
  • Verify widget data refreshes periodically
  1. Disable widget → coroutine stops:
  • Disable a widget from settings
  • Check logs - should see "Stopped refresh coroutine for [TYPE]"
  • Verify no more network requests for that widget
  1. Preview screen refresh:
  • Open each preview screen
  • Verify fresh data loads
  • Confirm no errors in logs

@jvsena42 jvsena42 self-assigned this Dec 26, 2025
@jvsena42 jvsena42 marked this pull request as draft December 26, 2025 14:03
@jvsena42 jvsena42 requested a review from Copilot December 26, 2025 14:14
@jvsena42 jvsena42 marked this pull request as ready for review December 26, 2025 14:14
Copy link
Contributor

Copilot AI left a 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 ConcurrentHashMap to 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

@jvsena42 jvsena42 requested a review from ovitrif December 26, 2025 14:21
@ovitrif ovitrif force-pushed the feat/nav3 branch 2 times, most recently from e57eef3 to 1eb159f Compare December 26, 2025 19:08
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.

3 participants