chore: fix a typo
All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m34s
All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m34s
This commit is contained in:
parent
8b57952344
commit
65e9c0fc19
2 changed files with 14 additions and 4 deletions
|
|
@ -38,6 +38,9 @@ export default function NotificationSettings() {
|
|||
.then(() => {
|
||||
setPushEnabled(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to unregister notifications:", error);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsRegistering(false);
|
||||
});
|
||||
|
|
@ -45,12 +48,15 @@ export default function NotificationSettings() {
|
|||
// Register notifications
|
||||
registerNotification()
|
||||
.then((result) => {
|
||||
if ("error" in result) {
|
||||
if ("error" in result && result.error) {
|
||||
console.error("Failed to register notifications:", result.error);
|
||||
} else {
|
||||
setPushEnabled(false);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to unregister notifications:", error);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsRegistering(false);
|
||||
});
|
||||
|
|
@ -121,7 +127,7 @@ export default function NotificationSettings() {
|
|||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{isInstalled() ? (
|
||||
{!isInstalled() ? (
|
||||
pushEnabled ? (
|
||||
<div className="flex items-start sm:items-center justify-between gap-4">
|
||||
<div className="space-y-1 flex-1">
|
||||
|
|
|
|||
|
|
@ -9,12 +9,16 @@ export async function registerNotification() {
|
|||
error: "E_PERMISSION_DENIED",
|
||||
};
|
||||
}
|
||||
|
||||
if (!("serviceWorker" in navigator) || !("PushManager" in window)) {
|
||||
return {
|
||||
error: "E_UNSUPPORTED",
|
||||
};
|
||||
}
|
||||
const registration = await navigator.serviceWorker.ready;
|
||||
try {
|
||||
const subscription = await registration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: process.env.VITE_PUBLIC_VAPID_KEY,
|
||||
applicationServerKey: import.meta.env.VITE_PUBLIC_VAPID_KEY,
|
||||
});
|
||||
await subscribe(subscription);
|
||||
// Store to local storage
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue