MemberMobileCardPWA

MemberMobileCardPWA Stimulus Controller

Manages Progressive Web App (PWA) functionality for mobile member cards. Extends MobileControllerBase for centralized connection handling.

Features:

  • Service worker registration with version management
  • SW update detection and user notification
  • Online/offline status detection and display
  • URL caching for offline access
  • Visual status indicators with Bootstrap styling

Constructor

new MemberMobileCardPWA()

Methods

applyUpdate()

Apply the service worker update

createUpdateToast()

Create update toast element

dismissUpdate()

Dismiss update toast

dispatchStatusEvent()

Dispatch connection status event for other controllers

handleSwMessage()

Handle service worker messages (e.g., SW_UPDATED)

notifyServiceWorker()

Notify service worker of connection state

onConnect()

Connect controller - called after base class connect

onConnectionStateChanged()

Called when connection state changes (from base class)

onDisconnect()

Disconnect controller - called after base class disconnect

refreshPageIfOnline()

Refresh page if online

(async) registerServiceWorker()

Register service worker and set up message handling

showUpdateToast()

Show update available toast

statusTargetConnected()

Handle status target connection - ensures indicator is displayed correctly This fires when the target element is connected to the DOM, which handles Turbo page restoration where targets might connect after onConnect runs

updateStatusDisplay()

Update the status display indicator (simple circle)

urlCacheTargetConnected()

Handle URL cache target connection

waitForActive()

Wait for service worker to become active