Fix banner not disappearing after enabling notifications
Modify the push notification banner component to immediately dismiss the banner upon user acceptance, ensuring the Chrome permission prompt can appear without obstruction and providing clearer error handling for subscription failures. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: be1d64b0-1371-4911-84cb-b3bb4611974c Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/tdiozLO Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
390f07d641
commit
0248e83a15
@ -35,15 +35,18 @@ export default function PushPromptBanner() {
|
||||
};
|
||||
|
||||
const accept = async () => {
|
||||
dismiss();
|
||||
try {
|
||||
await subscribeToPush();
|
||||
toast({ title: "Benachrichtigungen aktiviert", description: "Sie werden über neue Inhalte informiert." });
|
||||
} catch {
|
||||
} catch (err) {
|
||||
if (Notification.permission === "denied") {
|
||||
toast({ title: "Benachrichtigungen blockiert", description: "Bitte erlauben Sie Benachrichtigungen in Ihren Browsereinstellungen.", variant: "destructive" });
|
||||
} else {
|
||||
console.error("Push subscription error:", err);
|
||||
toast({ title: "Fehler", description: "Benachrichtigungen konnten nicht aktiviert werden. Bitte versuchen Sie es später erneut.", variant: "destructive" });
|
||||
}
|
||||
}
|
||||
dismiss();
|
||||
};
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user