From 86f28fa1b7ccda206e98f7bbfcb63721a068d977 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Thu, 29 Jan 2026 09:58:01 +0100 Subject: [PATCH] feat: auto-sync recipes and show sync button only in PWA mode - Auto-sync recipes every 30 minutes when online in PWA mode - Only show offline sync button when running as installed PWA - Detect standalone mode via display-mode media query and iOS check - Trigger initial sync on PWA install (appinstalled event) - Listen for online event to sync when coming back online - Store last sync time in localStorage to track sync intervals --- src/lib/components/OfflineSyncButton.svelte | 5 +- src/lib/stores/pwa.svelte.ts | 136 +++++++++++++++++++- 2 files changed, 137 insertions(+), 4 deletions(-) diff --git a/src/lib/components/OfflineSyncButton.svelte b/src/lib/components/OfflineSyncButton.svelte index 5b2fb81..9e3d42e 100644 --- a/src/lib/components/OfflineSyncButton.svelte +++ b/src/lib/components/OfflineSyncButton.svelte @@ -19,7 +19,8 @@ onMount(async () => { mounted = true; - await pwaStore.checkAvailability(); + // Initialize PWA store (checks standalone mode, starts auto-sync if needed) + await pwaStore.initialize(); }); async function handleSync() { @@ -147,7 +148,7 @@ } -{#if mounted} +{#if mounted && pwaStore.isStandalone}