feat(offline): hoist sync UI to homepage, slow auto-sync to weekly

Move OfflineSyncIndicator (logo pip) and OfflineSyncBanner from the
[recipeLang] layout/page to (main)/+layout.svelte and (main)/+page.svelte.
Sync is an app-wide concern, not recipe-specific, and surfacing it on the
homepage gives the entry point users actually see when they install the
PWA. Indicator pulls language from languageStore since (main) doesn't
have data.lang from a recipe-scoped load.

Drop the now-unused .banner-wrap CSS and OfflineSyncIndicator/Banner
imports from the recipe routes.

Auto-sync cadence:
- AUTO_SYNC_INTERVAL 30 min -> 1 week. Recipes don't change often enough
  to justify a half-hourly background download (the user explicitly
  wanted this dialed back).
- Internal poll tick 5 min -> 1 hour. Polling 12x an hour for a weekly
  event is wasted work; hourly is fine and still responsive when the
  weekly window opens.

Bump 1.65.3 -> 1.66.0.
This commit is contained in:
2026-05-04 22:21:16 +02:00
parent 0372c50084
commit 585c03a11e
6 changed files with 27 additions and 41 deletions
+5 -4
View File
@@ -2,7 +2,7 @@ import { browser } from '$app/environment';
import { isOfflineDataAvailable, getLastSync, clearOfflineData } from '$lib/offline/db';
import { downloadAllRecipes, type SyncResult, type SyncProgress } from '$lib/offline/sync';
const AUTO_SYNC_INTERVAL = 30 * 60 * 1000; // 30 minutes
const AUTO_SYNC_INTERVAL = 7 * 24 * 60 * 60 * 1000; // 1 week
const LAST_SYNC_KEY = 'bocken-last-sync-time';
type PWAState = {
@@ -152,12 +152,13 @@ function createPWAStore() {
startAutoSync() {
if (autoSyncInterval) return; // Already running
// Check every 5 minutes if we should sync
// Check hourly if we should sync — actual sync only fires once
// AUTO_SYNC_INTERVAL has elapsed since the last sync.
autoSyncInterval = setInterval(() => {
autoSync();
}, 5 * 60 * 1000); // Check every 5 minutes
}, 60 * 60 * 1000);
console.log('[PWA] Auto-sync enabled (every 30 minutes)');
console.log('[PWA] Auto-sync enabled (weekly)');
},
stopAutoSync() {