Skip to content

Fix widget updates: stale data after reboot, premature MidnightTrigger emit#3

Merged
mrknutte26 merged 2 commits intocopilot/update-fork-with-pr-289from
copilot/check-widget-update-issue
Mar 9, 2026
Merged

Fix widget updates: stale data after reboot, premature MidnightTrigger emit#3
mrknutte26 merged 2 commits intocopilot/update-fork-with-pr-289from
copilot/check-widget-update-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 9, 2026

Widgets were not updating after device reboot, and a race in PeriodCalculationWidgetUpdater could cause a brief stale-data render when period calculations changed.

Changes

  • BootReceiver — added updateAll() for all widgets after scheduling the midnight worker. Previously, scheduleNextMidnight() only queued a job for the next midnight; widgets kept showing cached RemoteViews until then or until the user opened the app.

  • PeriodCalculationWidgetUpdater.updateWidgets() — removed the MidnightTrigger.midnightTrigger.emit(Unit) call that preceded updateAll(). This emit was issued from inside CalculationsHelper.nextPeriod()'s .map {} block — before the new value had been returned by the map — so any active combine collector could recompose with the old nextPeriod value:

    dbWriteTrigger emits
      → nextPeriod().map { } starts
          → calculateNextPeriod() → new date
          → updateWidgets() launches IO coroutine   ← still inside map {}
      → map {} returns new date   ← nextPeriod() hasn't emitted yet when coroutine runs
    
    IO coroutine:
      → MidnightTrigger.emit(Unit)          ← combine fires with OLD nextPeriod value ⚠️
      → updateAll()                         ← fresh composition gets correct value ✓
    

    updateAll() alone is sufficient: each new Glance composition re-subscribes to dbWriteTrigger (replay = 1) and re-runs calculateNextPeriod() from scratch. MidnightTrigger.emit() is intentionally kept in MidnightWorker.doWork(), where it correctly signals the date roll-over at midnight to any active compositions.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-all/54h0s9kvb6g2sinako7ub77ku/gradle-8.13/lib/gradle-daemon-main-8.13.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Pull Request: #2

Merge this into my main

Then check why this app is still not updating the widgets. The widgets should update when the calculations change, they should change at midnight each day even if the app it self isn't open. They should also update when the app starts or when you reboot your phone. I suspect we do the update before the new calculations is done and therefore the widgets don't update as the should.

Check this, and make a new PR after your findings. If you don't find anything then document how the widgets updates today


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…nightTrigger emit

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate widget update functionality Fix widget updates: stale data after reboot, premature MidnightTrigger emit Mar 9, 2026
@mrknutte26 mrknutte26 marked this pull request as ready for review March 9, 2026 18:43
@mrknutte26 mrknutte26 merged commit bd27065 into copilot/update-fork-with-pr-289 Mar 9, 2026
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