-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Initialize groundwork for PWA support #9205
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
base: development
Are you sure you want to change the base?
Initialize groundwork for PWA support #9205
Conversation
|
@mtanmaykapil is attempting to deploy a commit to the eventyay Team on Vercel. A member of the Team first needs to authorize it. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideInitial groundwork for PWA support by conditionally registering a service worker when the app boots in browsers that support it. Sequence diagram for conditional service worker registration on app loadsequenceDiagram
actor User
participant BrowserWindow as BrowserWindow
participant App as EmberApp
participant Navigator as Navigator
participant ServiceWorker as ServiceWorkerGlobal
User->>BrowserWindow: Open application URL
BrowserWindow->>App: Boot app.js
App->>Navigator: Check serviceWorker support
alt serviceWorker supported
BrowserWindow->>BrowserWindow: Add load event listener
User->>BrowserWindow: Wait for window load
BrowserWindow->>Navigator: navigator.serviceWorker.register(/service-worker.js)
Navigator->>ServiceWorker: Install service worker
ServiceWorker-->>Navigator: Registration success/failure
else serviceWorker not supported
App-->>BrowserWindow: Skip service worker registration
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Consider moving the service worker registration into an Ember initializer or similar boot hook instead of at module top-level to better align with the app’s lifecycle and avoid side effects on import.
- It may be helpful to handle and log registration failures (e.g., catching
navigator.serviceWorker.registerrejections) so diagnosing PWA issues in production is easier.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving the service worker registration into an Ember initializer or similar boot hook instead of at module top-level to better align with the app’s lifecycle and avoid side effects on import.
- It may be helpful to handle and log registration failures (e.g., catching `navigator.serviceWorker.register` rejections) so diagnosing PWA issues in production is easier.
## Individual Comments
### Comment 1
<location> `app/app.js:19` </location>
<code_context>
+
+if ('serviceWorker' in navigator) {
+ window.addEventListener('load', () => {
+ navigator.serviceWorker.register('/service-worker.js');
+ });
+}
</code_context>
<issue_to_address>
**question:** Clarify whether service worker registration should occur in all environments or be gated by environment checks.
Unconditional registration will also run in local and test environments, potentially causing confusing caching behavior. Consider guarding this with an environment check (e.g., only in production or behind a config flag) to avoid unintended caching during development.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| if ('serviceWorker' in navigator) { | ||
| window.addEventListener('load', () => { | ||
| navigator.serviceWorker.register('/service-worker.js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Clarify whether service worker registration should occur in all environments or be gated by environment checks.
Unconditional registration will also run in local and test environments, potentially causing confusing caching behavior. Consider guarding this with an environment check (e.g., only in production or behind a config flag) to avoid unintended caching during development.
This PR adds the initial groundwork for Progressive Web App (PWA) support.
What this PR does
Notes
Fixes #9204
Summary by Sourcery
New Features: