Skip to content

Commit

Permalink
Added Suggestions by codeRabbit 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaJ2305 committed Nov 6, 2024
1 parent b708922 commit 8c1f489
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/components/Notifications/NotificationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ export default function NotificationsList({
try {
const reg = await navigator.serviceWorker.ready;

if (!reg.pushManager) return;
if (!reg.pushManager) {
Error({ msg: t("unsubscribe_failed") });
return;
}

setIsSubscribing(true);

Expand All @@ -313,32 +316,27 @@ export default function NotificationsList({
try {
await subscription.unsubscribe();

const data = {
pf_endpoint: "",
pf_p256dh: "",
pf_auth: "",
};

await request(routes.updateUserPnconfig, {
pathParams: { username },
body: data,
body: {
pf_endpoint: "",
pf_p256dh: "",
pf_auth: "",
},
});

setIsSubscribed("NotSubscribed");
} catch (e) {
Error({ msg: t("unsubscribe_failed") });
} finally {
setIsSubscribing(false);
}
} else {
setIsSubscribing(false);
}
} catch (e) {
Sentry.captureException(e);
Error({ msg: t("subscription_error") });
} finally {
setIsSubscribing(false);
}
};

async function subscribe() {
setIsSubscribing(true);
const response = await request(routes.getPublicKey);
Expand Down

0 comments on commit 8c1f489

Please sign in to comment.