Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Offline Functionality] Refresh Site Data after Emptying Replay Queue #146

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

julianrkung
Copy link
Collaborator

@julianrkung julianrkung commented Apr 27, 2021

What's new in this PR

This PR implements a channel for the service worker and client to communicate. This is used to trigger a data refresh once all requests stored offline have finished being replayed. We only refresh once the queue is fully empty in order to not lose any offline objects in the redux store that would otherwise be lost if we refreshed site data with requests still queued.

How to review

  1. npm run build to build a production environment
  2. serve -s build to run the production environment
  3. Go to localhost:5000 and clear your site data to make sure you get the latest changes in the PR
  4. Refresh the page to make sure you get the latest service worker installed
  5. log in using the credentials username: admin ; password: test.
  6. Go offline by opening up devtools --> Application --> Service Workers --> check the "offline" box
  7. Create 2 "Inventory updates" while offline and make sure that they haven't persisted to Airtable
  8. Uncheck the "Offline" box from step 6
  9. Check that the inventory updates have now persisted to Airtable and that in console you should've seen a Offline requests finished sending. Refreshing data... log message
  10. Check the redux store to make sure that the 2 inventory updates you created have Airtable IDs and no longer have offline IDs

Relevant Links

Online sources

https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-background-sync.Queue

Related PRs

Next steps

Screenshots

CC: @julianrkung

@julianrkung julianrkung requested a review from wangannie April 27, 2021 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant