Skip to content

fix: skip auto refresh for disabled widgets#757

Open
jvsena42 wants to merge 5 commits intomasterfrom
fix/disabled-widgets-refresh
Open

fix: skip auto refresh for disabled widgets#757
jvsena42 wants to merge 5 commits intomasterfrom
fix/disabled-widgets-refresh

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Jan 30, 2026

Closes #197

This PR skips auto-refresh for disabled widgets, saving resources by only syncing data for widgets that are actually enabled.

Description

The app was continuously syncing widget data in the background for all widgets, regardless of whether they were enabled. This wasted network and battery resources. Changes:

  1. Replaces the always-on refresh logic with selective refresh based on enabled widget state
  2. Tracks refresh jobs per widget type using a ConcurrentHashMap
  3. Starts/stops refresh coroutines dynamically when widgets are enabled/disabled
  4. Adds manual refresh when opening widget preview screens (since disabled widgets won't auto-refresh)

Preview

Screen_recording_20260130_103016.webm

QA Notes

1. Enable widget - coroutine starts

  1. Enable a widget from settings
  2. Check logs - should see "Updated $widgetType widget successfully"
  3. Verify widget data refreshes periodically

2. Disable widget - coroutine stops

  1. Disable a widget from settings
  2. Check logs - should see "Stopped refresh coroutine for [TYPE]"
  3. Verify no more network requests for that widget

3. Preview screen refresh

  1. Open each preview screen (News, Facts, Blocks, Weather, Price)
  2. Verify fresh data loads
  3. Confirm no errors in logs

@claude

This comment has been minimized.

@jvsena42 jvsena42 self-assigned this Jan 30, 2026
@jvsena42 jvsena42 requested a review from ovitrif January 30, 2026 13:33
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Code Review

Issue: Missing Throwable parameter in Logger call

Location: app/src/main/java/to/bitkit/repositories/WidgetsRepo.kt:196

The Logger call in the .onFailure block should include the Throwable parameter e as the second positional argument to capture error details.

According to CLAUDE.md, Logger calls within .onFailure blocks should pass the Throwable:

.onFailure {
    Logger.error("Failed", it, context = TAG)
}

Current code:

.onFailure { e ->
    Logger.verbose("Failed to update $widgetType widget", context = TAG)
}

Should be:

.onFailure { e ->
    Logger.verbose("Failed to update $widgetType widget", e, context = TAG)
}

This ensures error details are properly captured in logs.

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.

Widgets feed data should not sync periodically if the widget is not enabled

1 participant