diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-15 07:21:17 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 02:48:28 +0000 |
| commit | e846505925b7e537425cb614123e04f263936056 (patch) | |
| tree | d17494ee723397a4f21ab6298cbbfa043b820b12 /android/app | |
| parent | 5250747bd044a744df73c3686cd528d7599139b8 (diff) | |
fix(widget): re-arm periodic refresh on every onUpdate, not just onEnabled
onEnabled only fires when the first widget instance is added to a home
screen, so if the periodic RefreshWorker job is ever silently dropped
(an app reinstall can clear WorkManager's persisted schedule without
the widget itself being removed/re-added -- exactly what happens when
sideloading a new APK build, as opposed to a Play Store update), there
was no way for it to come back except manually removing and re-adding
the widget. onUpdate fires far more often (reboot, periodic OS ticks)
and now also re-arms the schedule (a no-op via KEEP if already running).
Root-caused via manual refresh restoring all missing content instantly
(rules out a data/rendering bug) plus the widget only showing one
stale morning event beforehand (consistent with the periodic job
having stopped ticking hours earlier, right around today's APK
reinstalls).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VTUSAEKfsPc6WGDq45yPHD
Diffstat (limited to 'android/app')
| -rw-r--r-- | android/app/src/main/java/org/terst/doot/widget/DootWidgetReceiver.kt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/android/app/src/main/java/org/terst/doot/widget/DootWidgetReceiver.kt b/android/app/src/main/java/org/terst/doot/widget/DootWidgetReceiver.kt index 94ff4b6..83f0a7b 100644 --- a/android/app/src/main/java/org/terst/doot/widget/DootWidgetReceiver.kt +++ b/android/app/src/main/java/org/terst/doot/widget/DootWidgetReceiver.kt @@ -19,6 +19,13 @@ class DootWidgetReceiver : GlanceAppWidgetReceiver() { ) { super.onUpdate(context, appWidgetManager, appWidgetIds) RefreshWorker.runOnce(context) + // Self-healing: onEnabled only fires when the first widget instance is + // added, so if the periodic job is ever silently dropped (e.g. an app + // reinstall clears WorkManager's persisted schedule without the widget + // itself being removed/re-added), it would otherwise never come back + // until the user manually removes and re-adds the widget. schedule() + // uses KEEP, so this is a no-op when the job is already running. + RefreshWorker.schedule(context) } override fun onEnabled(context: Context) { |
