T5: Offline queue + background sync — fix missing offline banner, add API GET caching to SW #24
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The offline queue implementation was mostly complete from a prior run, but the
#offlineBannerHTML element was missing from the DOM. TheshowOfflineBanner()andhideOfflineBanner()functions referenceddocument.getElementById("offlineBanner")but no element with that ID existed. ThequeueCountBadgespan inside the banner was also missing.Additionally, the Service Worker passed through all API calls without caching, so API GET requests (like loading the assets list) would fail when offline.
Fix
#offlineBannerHTML element after the header div: amber banner with📡 Offline mode — changes will sync when connectedtext andqueueCountBadgespanstatic/sw.js): API GET calls now use network-first with cache fallback strategy (POST/PUT/DELETE still pass through). Bumped cache version fromcanteen-v1tocanteen-v2.Files Changed
static/index.html: Added offline banner HTML element (7 lines)static/sw.js: Added API GET caching strategy, bumped cache version (+15/-2 lines)Commits
37ba54b(on top of6229966)Verification
curl -sk https://localhost:8901/sw.jsreturns updated SW with v2 cachecurl -sk https://localhost:8901/ | grep offlineBannerreturns 3 matches (CSS definition, JS reference, HTML element)