From 7d3d0063852df91b28f6b69feac9a468f8fb994e Mon Sep 17 00:00:00 2001 From: poketonova Date: Mon, 8 Jun 2026 16:05:49 -0600 Subject: [PATCH] feat: implement iOS Safari launch-refresh fallback logic --- src/App.vue | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/App.vue b/src/App.vue index 78450c0..dbfca18 100644 --- a/src/App.vue +++ b/src/App.vue @@ -213,7 +213,28 @@ function createPortfolio() { router.push(`/portfolio/${p.id}`) } +/** + * iOS Safari PWA Fallback Refresh + * Since iOS lacks the Periodic Background Sync API, PWAs often launch with stale data. + * This logic checks the last known activity time and triggers a refresh if the app + * has been inactive for more than 4 hours, ensuring users always see fresh prices. + */ +function checkStaleLaunch() { + const STALE_THRESHOLD = 1000 * 60 * 60 * 4 // 4 hours + const lastActive = localStorage.getItem('rarebox_last_active') + const now = Date.now() + + if (lastActive && (now - parseInt(lastActive)) > STALE_THRESHOLD) { + console.log('[Rarebox] Stale launch detected on iOS, refreshing...') + hardRefresh() + } + localStorage.setItem('rarebox_last_active', now.toString()) +} + onMounted(async () => { + if (window.navigator.standalone || window.matchMedia('(display-mode: standalone)').matches) { + checkStaleLaunch() + } await store.init() store.autoSnapshot() // record daily price snapshot for chart history })