mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
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:
parent
88b3f68a1f
commit
2cdf015217
1 changed files with 3 additions and 4 deletions
|
|
@ -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}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue