generated from eblume/project-template
feat(heph-pwa): re-fetch the current view when the app regains focus
The PWA shares the daemon's store with the TUI/desktop popover but only re-fetched on a view switch or action — so a task marked done elsewhere left a stale list on screen. Reload the current view on visibilitychange→visible (switch back to the phone, unlock, tab re-show), skipping it mid-modal/search. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0036c1a284
commit
271c609c14
2 changed files with 18 additions and 1 deletions
|
|
@ -785,6 +785,23 @@ function buildShell() {
|
|||
async function init() {
|
||||
buildShell();
|
||||
document.addEventListener("keydown", onKeydown);
|
||||
|
||||
// The PWA shares the daemon's store with the TUI / desktop popover, but only
|
||||
// re-fetches on a view switch or an action. So another surface marking a task
|
||||
// done leaves a stale list on screen until then. Re-fetch the current view
|
||||
// whenever the app regains focus (switching back to the phone, unlock, tab
|
||||
// re-show) — but not while a modal or search is mid-interaction.
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (
|
||||
document.visibilityState === "visible" &&
|
||||
state.client.configured &&
|
||||
!modalOpen() &&
|
||||
!state.search
|
||||
) {
|
||||
reload();
|
||||
}
|
||||
});
|
||||
|
||||
render();
|
||||
reload();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Service worker: cache the app shell so heph launches offline. Data is never
|
||||
// cached — every /rpc call must hit the live hub (and POSTs aren't cacheable
|
||||
// anyway). Bump CACHE when shell assets change to evict the old set.
|
||||
const CACHE = "heph-pwa-v2";
|
||||
const CACHE = "heph-pwa-v3";
|
||||
const SHELL = [
|
||||
"./",
|
||||
"./index.html",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue