# Offline Mode Support
- https://developer.chrome.com/docs/workbox/modules/workbox-background-sync
Assumptions
- User needs to login before going offline. Offline can't sign in.
- Users are informed of the offline status and the limitations it imposes on application functionality.
- POST requests are iodomeponent. (multiple post requests don't duplicate data)
## Worker Architecture
```
[Service Worker] --(listens for)-- [Online/Offline Events]
|
|---(online event)--> [Send "refresh_token" Message] --(to)--> [Client-Side Application]
|
|---(performs)--> [Token Refresh]
|
|<----------------(token refreshed message)--------------|
|
v
[Workbox Background Sync] --(manages)--> [Queue of Failed Requests]
|
|---(on token refresh)--> [Retry Queued Requests]
```
## Requirements
- GET via the Digital Forms server API to retrieve form IDs
- POST via the Digital Forms server API to update the status of form IDs (e.g. leased, printed, spoiled, etc.)
- GET via the ICBC server API to retrieve driver’s license information
- GET via the ICBC server API to retrieve vehicle license plate information
- POST via the Digital Forms server to store the user’s entered form data (could be done multiple times in a single workflow to save progress)
- GET via the Digital Forms server API to retrieve a list of all forms previously completed by the user
- GET via the Digital Forms server API to retrieve the details of a previously completed form
### Offline mode support:
- GET via the Digital Forms server API to retrieve form IDs
- POST via the Digital Forms server API to update the status of form IDs (e.g. leased, printed, spoiled, etc.)
- POST via the Digital Forms server to store the user’s entered form data (could be done multiple times in a single workflow to save progress)
## Queue
Workbox does not support order across multiple requests. Only on the same request.
- [ ] Decide Queue implementation **If order matters we need a custom solution**
- [ ] Cache Get requests? Have to deal with data staleness.
- [ ] data sync on connectivity
- [ ] degredation of services UI