mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-03-28 17:42:45 +01:00
fix: Implement proper toggle logic for notification enable/disable
Previous implementation always disabled notifications when permission was granted, regardless of current state. This made it impossible to re-enable notifications after disabling them. Now properly checks localStorage state and toggles: - If currently enabled → disable (show "Notifications disabled") - If currently disabled → enable (show "Notifications enabled") This fixes the issue where clicking the toggle when disabled would show "Notifications disabled" instead of enabling them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -726,10 +726,20 @@ async function handleNotificationToggle() {
|
||||
const permission = getNotificationPermission();
|
||||
|
||||
if (permission === 'granted') {
|
||||
// Already granted - toggle off
|
||||
localStorage.setItem('mc_notifications_enabled', 'false');
|
||||
updateNotificationToggleUI();
|
||||
showNotification('Notifications disabled', 'info');
|
||||
// Permission granted - toggle between enabled/disabled
|
||||
const isCurrentlyEnabled = localStorage.getItem('mc_notifications_enabled') === 'true';
|
||||
|
||||
if (isCurrentlyEnabled) {
|
||||
// Turn OFF
|
||||
localStorage.setItem('mc_notifications_enabled', 'false');
|
||||
updateNotificationToggleUI();
|
||||
showNotification('Notifications disabled', 'info');
|
||||
} else {
|
||||
// Turn ON
|
||||
localStorage.setItem('mc_notifications_enabled', 'true');
|
||||
updateNotificationToggleUI();
|
||||
showNotification('Notifications enabled', 'success');
|
||||
}
|
||||
} else if (permission === 'denied') {
|
||||
// Blocked - show help message
|
||||
showNotification('Notifications are blocked. Change browser settings: Settings → Site Settings → Notifications', 'warning');
|
||||
|
||||
Reference in New Issue
Block a user