-
Notifications
You must be signed in to change notification settings - Fork 398
✨(service-worker) offline doc management #94
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b27973b
to
85a8da5
Compare
4fe7c85
to
1029aef
Compare
6033ab8
to
834cae8
Compare
Add a new environment variable to enable or disable the service worker in development mode. By default, the service worker is disabled in development mode, it can cause problems when developing the application with the hmr. It can creates useless log in the console as well. We can easily enable it by setting NEXT_PUBLIC_SW_DEACTIVATED to false in the .env.development file. We will use this new var to not use the service worder with the CI as well.
This commit adds the service worker api to the impress app. The service worker api will cache the api calls in the indexdb. We are using the network first strategy to fetch the data. If the network is not available, we will fetch the data from the indexdb. To do that, we create a custom plugin (ApiPlugin).
Add offline docs update to the service worker. We use the Network fisrt strategy, if the network is down, we will update the doc in the indexDB and serve it from there. When the connection is back, we will send the doc to the server.
Export the storage of docs to a separate class `DocsDB` that will be responsible for storing / retrieving / synching docs from indexedDB.
Add offline docs create to the service worker. We use the Network fisrt strategy, if the network is down, we will create the doc in the indexDB and serve it from there. When the connection is back, we will send the doc to the server.
Add offline docs delete to the service worker. We use the Network fisrt strategy, if the network is down, we will delete the doc in the indexDB. When the connection is back, we will remove the doc to the server.
We override the perform_create method of the DocumentViewSet to save the document with the id provided if a id is provided in the request. We do that because in offline mode we will create the document locally and we will need to save it with the id created locally to have our next requests to the server to be able to find the document with the id provided.
We add a buildId to the service worker to force the browser to update the service worker when the buildId changes. Before we were on the tag version, but the browser was not updating the service worker easily on the staging environment.
Firefox does not trigger the request everytime the user leaves the page. Plus the request is not intercepted by the service worker. So we prevent the default behavior to have the popup asking the user if he wants to leave the page, by adding the popup, we let the time to the request to be sent, and intercepted by the service worker (for the offline part). We also add a toast to inform the user that the document has been saved, it will make it more obvious that the document has been saved if a firefox user come back from the popup to the page.
Add unit tests for: - ApiPlugin - RequestSerializer - SyncManager
Add a conf files to the service worker to store the development urls. If someone wants to change the urls, they can do it in the conf file, it is more intuitive than changing the urls in the service worker file.
The service worker is now in the features folder. It is more a feature than a core part of the app.
Create useSWRegister hook, which will be used to register the service worker in the app.
834cae8
to
d33538f
Compare
AntoLC
added a commit
that referenced
this pull request
Jul 2, 2024
Added: - Manage the document's right (#75) - Update document (#68) - Remove document (#68) - (docker) dockerize dev frontend (#63) - (backend) list users with email filtering (#79) - (frontend) add user to a document (#52) - (frontend) invite user to a document (#52) - (frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - (frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - (frontend) Add beta tag on logo (#121) Changed: - Change site from Impress to Docs (#76) - Generate PDF from a modal (#68) - 🔧 (helm) sticky session by request_uri for signaling server (#78) - (frontend) change logo (#84) - (frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - Fix the break line when generate PDF (#84) Delete: - Remove trigger workflow on push tags on CI (#68) - (frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 2, 2024
Added: - Manage the document's right (#75) - Update document (#68) - Remove document (#68) - (docker) dockerize dev frontend (#63) - (backend) list users with email filtering (#79) - (frontend) add user to a document (#52) - (frontend) invite user to a document (#52) - (frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - (frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - (frontend) Add beta tag on logo (#121) Changed: - Change site from Impress to Docs (#76) - Generate PDF from a modal (#68) - 🔧 (helm) sticky session by request_uri for signaling server (#78) - (frontend) change logo (#84) - (frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - Fix the break line when generate PDF (#84) Delete: - Remove trigger workflow on push tags on CI (#68) - (frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 3, 2024
Added: - Manage the document's right (#75) - Update document (#68) - Remove document (#68) - (docker) dockerize dev frontend (#63) - (backend) list users with email filtering (#79) - (frontend) add user to a document (#52) - (frontend) invite user to a document (#52) - (frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - (frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - (frontend) Add beta tag on logo (#121) Changed: - Change site from Impress to Docs (#76) - Generate PDF from a modal (#68) - 🔧 (helm) sticky session by request_uri for signaling server (#78) - (frontend) change logo (#84) - (frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - Fix the break line when generate PDF (#84) Delete: - Remove trigger workflow on push tags on CI (#68) - (frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 3, 2024
Added: - Manage the document's right (#75) - Update document (#68) - Remove document (#68) - (docker) dockerize dev frontend (#63) - (backend) list users with email filtering (#79) - (frontend) add user to a document (#52) - (frontend) invite user to a document (#52) - (frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - (frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - (frontend) Add beta tag on logo (#121) Changed: - Change site from Impress to Docs (#76) - Generate PDF from a modal (#68) - 🔧 (helm) sticky session by request_uri for signaling server (#78) - (frontend) change logo (#84) - (frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - Fix the break line when generate PDF (#84) Delete: - Remove trigger workflow on push tags on CI (#68) - (frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 3, 2024
Added: - 🛂(frontend) Manage the document's right (#75) - ✨(frontend) Update document (#68) - ✨(frontend) Remove document (#68) - 🐳(docker) dockerize dev frontend (#63) - 👔(backend) list users with email filtering (#79) - ✨(frontend) add user to a document (#52) - ✨(frontend) invite user to a document (#52) - 🛂(frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - 🌐(frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - ⚗️(frontend) Add beta tag on logo (#121) Changed: - ♻️(frontend) Change site from Impress to Docs (#76) - ✨(frontend) Generate PDF from a modal (#68) - 🔧(helm) sticky session by request_uri for signaling server (#78) - ♻️(frontend) change logo (#84) - ♻️(frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - 🐛(frontend) Fix the break line when generate PDF (#84) Delete: - 💚(CI) Remove trigger workflow on push tags on CI (#68) - 🔥(frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 3, 2024
Added: - 🛂(frontend) Manage the document's right (#75) - ✨(frontend) Update document (#68) - ✨(frontend) Remove document (#68) - 🐳(docker) dockerize dev frontend (#63) - 👔(backend) list users with email filtering (#79) - ✨(frontend) add user to a document (#52) - ✨(frontend) invite user to a document (#52) - 🛂(frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - 🌐(frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - ⚗️(frontend) Add beta tag on logo (#121) Changed: - ♻️(frontend) Change site from Impress to Docs (#76) - ✨(frontend) Generate PDF from a modal (#68) - 🔧(helm) sticky session by request_uri for signaling server (#78) - ♻️(frontend) change logo (#84) - ♻️(frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - 🐛(frontend) Fix the break line when generate PDF (#84) Delete: - 💚(CI) Remove trigger workflow on push tags on CI (#68) - 🔥(frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 3, 2024
Added: - 🛂(frontend) Manage the document's right (#75) - ✨(frontend) Update document (#68) - ✨(frontend) Remove document (#68) - 🐳(docker) dockerize dev frontend (#63) - 👔(backend) list users with email filtering (#79) - ✨(frontend) add user to a document (#52) - ✨(frontend) invite user to a document (#52) - 🛂(frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - 🌐(frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - ⚗️(frontend) Add beta tag on logo (#121) Changed: - ♻️(frontend) Change site from Impress to Docs (#76) - ✨(frontend) Generate PDF from a modal (#68) - 🔧(helm) sticky session by request_uri for signaling server (#78) - ♻️(frontend) change logo (#84) - ♻️(frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - 🐛(frontend) Fix the break line when generate PDF (#84) Delete: - 💚(CI) Remove trigger workflow on push tags on CI (#68) - 🔥(frontend) Remove coming soon page (#121)
AntoLC
added a commit
that referenced
this pull request
Jul 3, 2024
Added: - 🛂(frontend) Manage the document's right (#75) - ✨(frontend) Update document (#68) - ✨(frontend) Remove document (#68) - 🐳(docker) dockerize dev frontend (#63) - 👔(backend) list users with email filtering (#79) - ✨(frontend) add user to a document (#52) - ✨(frontend) invite user to a document (#52) - 🛂(frontend) manage members (update role / list / remove) (#81) - ✨(frontend) offline mode (#88) - 🌐(frontend) translate cgu (#83) - ✨(service-worker) offline doc management (#94) - ⚗️(frontend) Add beta tag on logo (#121) Changed: - ♻️(frontend) Change site from Impress to Docs (#76) - ✨(frontend) Generate PDF from a modal (#68) - 🔧(helm) sticky session by request_uri for signaling server (#78) - ♻️(frontend) change logo (#84) - ♻️(frontend) pdf has title doc (#84) - ⚡️(e2e) unique login between tests (#80) - ⚡️(CI) improve e2e job (#86) - ♻️(frontend) improve the error and message info ui (#93) - ✏️(frontend) change all occurences of pad to doc (#99) Fixed: - 🐛(frontend) Fix the break line when generate PDF (#84) Delete: - 💚(CI) Remove trigger workflow on push tags on CI (#68) - 🔥(frontend) Remove coming soon page (#121)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
We will be able to manage our documents offline (create / update /delete).
We created a custom WorkboxPlugin to intercept the requests and created a queue system to replay when a connection is found the requests made offline.
Proposal
Demo
scrnli_6_20_2024_10-13-57.PM.webm