fix: Browser Notifications switch stays on after the browser denies permission (#32170)

Turning on Browser Notifications in a browser that blocks them showed an error, but the switch stayed on even though nothing was saved. The switch now turns back off when the browser denies permission.

Fixes #32024
This commit is contained in:
Classic298 2026-10-10 17:49:05 +02:00 • committed by GitHub
parent 88b3f68a1f
commit 2cdf015217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -61,13 +61,13 @@
}
const toggleNotifications = async () => {
if (!notificationEnabled) {
if (notificationEnabled) {
const permission =
'Notification' in window ? await Notification.requestPermission() : 'denied';
if (permission === 'granted') {
notificationEnabled = true;
saveSettings({ notificationEnabled });
} else {
notificationEnabled = false;
toast.error(
$i18n.t(
'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
@ -75,7 +75,6 @@
);
}
} else {
notificationEnabled = false;
saveSettings({ notificationEnabled });
}
};
@ -203,7 +202,7 @@
{$i18n.t('settings.personal.notifications.browserNotifications.label')}
</span>
<Switch
state={notificationEnabled}
bind:state={notificationEnabled}
ariaLabel={$i18n.t('settings.personal.notifications.browserNotifications.label')}
on:change={toggleNotifications}
/>