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

Fixing NotificationsList on Service Worker #8686

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

Conversation

vishwansh01
Copy link
Contributor

Proposed Changes

@ohcnetwork/care-fe-code-reviewers
Screenshot (35)

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

@vishwansh01 vishwansh01 requested a review from a team as a code owner October 1, 2024 14:29
Copy link

netlify bot commented Oct 1, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 413f65a
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/670548b273e3d000097114e6
😎 Deploy Preview https://deploy-preview-8686--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nihal467
Copy link
Member

nihal467 commented Oct 8, 2024

LGTM

Copy link
Member

@khavinshankar khavinshankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishwansh01 the logic looks, just some suggestions on readability

setIsSubscribed("SubscribedOnThisDevice");
} else {
setIsSubscribed("SubscribedOnAnotherDevice");
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have a try on line 223, this can be removed

Comment on lines +247 to +258
if (
navigator.serviceWorker !== null &&
navigator.serviceWorker !== undefined
) {
if (
status === "NotSubscribed" ||
status === "SubscribedOnAnotherDevice"
) {
subscribe();
} else {
unsubscribe();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit hard to follow, let's re-write it

Suggested change
if (
navigator.serviceWorker !== null &&
navigator.serviceWorker !== undefined
) {
if (
status === "NotSubscribed" ||
status === "SubscribedOnAnotherDevice"
) {
subscribe();
} else {
unsubscribe();
}
if (!navigator.serviceWorker) {
return;
}
if (["NotSubscribed", "SubscribedOnAnotherDevice"].includes(status)) {
subscribe();
} else {
unsubscribe();
}

pf_p256dh: "",
pf_auth: "",
};
if (reg.pushManager !== null && reg.pushManager !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here too, let's negate the logic and return (similar to the previous comment), that makes it more readable

@bodhish
Copy link
Member

bodhish commented Oct 18, 2024

@vishwansh01 can you update the status here?

@AdityaJ2305
Copy link
Contributor

Hey @bodhish, Since @vishwansh01 hasn’t responded to the requested changes on the PR, can I create a new PR for this issue if he remains inactive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError in NotificationsList Component on Service Worker Subscription Fetch
5 participants